#include <bits/stdc++.h>

#define pb push_back
#define ll long long
#define pii pair<int, int>
#define xx first
#define yy second
#define MAXN 200010
#define MAXM 15

using namespace std;

int n, m, dp[MAXN][MAXM];
bool dal[MAXN][MAXM];
string t, s;

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    cin>>t>>s;
    n=t.size(); m=s.size();
    cout<<t<<endl; cout<<s<<endl;

    if (t[0]==s[0]) { dp[0][0]=1; dal[0][0]=1; }
    else dp[0][0]=0;
    for (int j=1; j<m; j++) dp[0][j]=0;

    ///cout<<dp[0][0]<<endl;

    for (int i=1; i<n; i++)
    {
        for (int j=0; j<m; j++)
        {
            if (t[i]==s[j])
            {
                if (j==0) { dp[i][j]=dp[i-1][j]+1; dal[i][j]=1; }
                else
                {
                    if (dp[i-1][j]+1<dp[i-1][j-1]) dal[i][j]=1;
                    else dal[i][j]=0;
                    dp[i][j]=min(dp[i-1][j-1], dp[i-1][j]+1);
                }
            }
            else
            {
                dp[i][j]=dp[i-1][j];
                dal[i][j]=0;
            }
            ///cout<<i<<" "<<j<<" "<<dp[i][j]<<" "<<dal[i][j]<<endl;
        }
    }

    cout<<dp[n-1][m-1]<<endl;

    int i=n-1, j=m-1;
    while (i>=0)
    {
        ///cout<<i<<" "<<j<<" "<<dal[i][j]<<endl;
        if (dal[i][j]) { t[i]='*'; }
        if (t[i]==s[j]) j--;
        i--;

    }

    cout<<t;
}