#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define sc second
#define th third
#define fo fourth
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ldb double
#define endl "\n"
#define MAXN 200007
#define MAXM 17
int dp[MAXN][MAXM];
int br[MAXN];
vector<int> v;
int main()
{
    string a,b;
    cin>>a>>b;
    int n=a.size(),m=b.size();
    for(int j=0;j<m;j++)
    {
        if(a[0]==b[j])
        {
            dp[0][j]=1;
        }
    }
    if(m==1 && a[0]==b[0]) v.pb(0);
    for(int i=1;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(a[i]==b[j])
            {
                dp[i][j]=dp[i-1][j]+1;
                if(j!=0) dp[i][j]=min(dp[i][j],dp[i-1][j-1]);
                if(dp[i-1][j]+1>dp[i-1][j-1])
                {
                    v.pb(i);
                }
                else
                {
                    v.clear();
                }
            }
            else dp[i][j]=dp[i-1][j];
        }
    }
    cout<<dp[n-1][m-1]<<" ";
    cout<<endl;
    for(int i=0;i<v.size();i++)
    {
        a[v[i]]='*';
    }
    cout<<a;
    return 0;
}