#include <bits/stdc++.h>

using namespace std;

#define ll long long
const ll MAXN=105,LINF=1e18,MOD=1e9+7,INF=1e9;
const double EPS=1e-9;
#define fi first
#define se second
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mid (l+r)/2
#define sz(a) int((a).size())
#define all(a) a.begin(),a.end()
#define mod 1000000007LL
#define pb push_back
#define endl "\n"
#define PRINT(x) cerr<<#x<<'-'<<x<<endl<<flush;
#define getunique(v) {sort(all(v)); v.erase(unique(all(v)), v.end());}
#define pb push_back
#define pf push_front
#define ppf pop_front
#define ppb pop_back
#define PRINTvec(x) { cerr<<#x<<"-"; for(int i=0;i<sz(x);i++) cerr<<x[i]<<" "; cerr<<endl; }

ll n,m,k,q,x,y,z,l,res=0;
string s,t;
ifstream in;
ofstream out;

#ifdef ONLINE_JUDGE
    #define in cin
    #define out cout
#endif

void solve(){
    cin>>s>>t;
    n=sz(s),m=sz(t);
    vector<vector<vector<int>>> dp(n,vector<vector<int>>(m,vector<int>(4)));
    for(int j=0;j<m;j++){
        if(s[0]==t[j]){
            dp[0][j][0]=1;
            dp[0][j][1]=true;
            dp[0][j][2]=0;
            dp[0][j][3]=0;
        }
        else{
            dp[0][j][0]=0;
            dp[0][j][1]=false;;
            dp[0][j][2]=0;
            dp[0][j][3]=0;
        }
    }
    for(int i=1;i<n;i++){
        for(int j=0;j<m;j++){
            if(s[i]==t[j]){
                dp[i][j][0]=dp[i-1][j][0]+1;
                dp[i][j][1]=true;
                dp[i][j][2]=i-1;
                dp[i][j][3]=j;
                if(j!=0){
                    if(dp[i-1][j-1][0]<dp[i][j][0]){
                        dp[i][j][0]=dp[i-1][j-1][0];
                        dp[i][j][1]=false;
                        dp[i][j][2]=i-1;
                        dp[i][j][3]=j-1;
                    }
                }
            }
            else{
                dp[i][j][0]=dp[i-1][j][0];
                dp[i][j][1]=false;
                dp[i][j][2]=i-1;
                dp[i][j][3]=j;
            }
        }
    }
    /*
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cout<<"("<<s.substr(0,i+1)<<","<<t.substr(0,j+1)<<")="<<dp[i][j][0]<<" "<<dp[i][j][1]<<" "<<dp[i][j][2]<<" "<<dp[i][j][3]<<endl;
        }
    }
    */
    int i=n-1,j=m-1;
    while(true){
        ///PRINT(i); PRINT(j);
        if(dp[i][j][1]){
            s[i]='*';
        }
        if(i==0) break;
        int tmpi=dp[i][j][2],tmpj=dp[i][j][3];
        i=tmpi;
        j=tmpj;
    }
    cout<<dp[n-1][m-1][0]<<endl;
    cout<<s<<endl;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
        in.open("D:\\UROS\\Programiranje\\input.in",ios::in);
        out.open("D:\\UROS\\Programiranje\\output.out",ios::trunc | ios::out);
    #endif
    ///freopen("input.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    int t;
    ///cin>>t;
    t=1;
    while(t--){
        solve();
    }
    return 0;
}