#include <iostream>
#include <string.h>

using namespace std;

int main()
{
    string s,r;
    cin >> s;
    cin >> r;
    int n=s.size(),m=r.size(),i,j,k;
    int h[m],w[m][n];
    for (i=0;i<m;i++)
    {
        h[i]=0;
    }
    for (i=0;i<n;i++)
    {
        for (j=m-1;j>=0;j--)
        {
            if (s[i]==r[j] && (h[j]<h[j-1] || j==0))
            {
                w[j][h[j]]=i;
                h[j]++;
            }
        }
    }
    cout << h[m-1] << endl;
    j=m-1;
    while (j>0 && h[j-1]==h[m-1])
    {
        j--;
    }
    k=0;
    for (i=0;i<n;i++)
    {
        if (i==w[j][k])
        {
            cout << "*";
            k++;
        }
        else
            cout << s[i];
    }
    cout << endl;
    return 0;
}