#include<bits/stdc++.h>
using namespace std;
int dp[200010][110];
vector<int>c;
int main()
{
    string t,s;
    cin >> t >> s;
    int a=t.length(),b=s.length();
    for (int i=0; i<b; i++)
        dp[0][i]=(t[0]==s[i]);
    for (int i=1; i<a; i++)
    {
        for (int j=0; j<b; j++)
        {
            if (t[i]!=s[j])
            {
                dp[i][j]=dp[i-1][j];
                continue;
            }
            dp[i][j]=dp[i-1][j]+1;
            if (j)
            {
                if (dp[i][j]<=dp[i-1][j-1])
                    c.push_back(i);
                else
                {
                    dp[i][j]=dp[i-1][j-1];               
                    c.clear();                  
                }
            }
        }
    }
    cout << dp[a-1][b-1] << "\n";
    int k=c.size();
    for (int i=0; i<k; i++)
        t[c[i]]='*';
    cout << t;
    return 0;
}