#define here cerr<<"---------------------------\n"
#include <bits/stdc++.h>
#define ld double
#define ll long long
#define ull unsigned long long
#define llinf 100000000000000000LL // 10^17
#define iinf 2000000000 // 2*10^9
#define pb push_back
#define popb pop_back
#define fi first
#define sc second
#define endl '\n'
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define sz(a) int(a.size())
#define all(a) a.begin(),a.end()
using namespace std;
#define maxn 200005
#define maxm 15
ll n,m;
struct lasti{
    ll i,j;
    bool da;
};
lasti last[maxn][maxm];
ll dp[maxn][maxm];
ll a[maxn];
ll b[maxm];
string s,t;
int main(){
	ios_base::sync_with_stdio(false);cerr.tie(0);cout.tie(0);cin.tie(0);
    cin >> s >> t;
    n = sz(s);
    m = sz(t);
    for(ll i = 1;i<=n;i++) a[i] = (s[i-1]-'a');
    for(ll i = 1;i<=m;i++) b[i] = (t[i-1]-'a');
    for(ll i = 1;i<=n;i++){
        dp[i][1] = dp[i-1][1]+(a[i]==b[1]);
        last[i][1] = {i-1,1,a[i]==b[1]};
    }
    for(ll i = 1;i<=m;i++){
        if(a[1]==b[i]){
            dp[1][i] = 1;
            last[1][i] = {0,0,1};
        }
    }
    for(ll i = 2;i<=n;i++){
        for(ll j = 2;j<=m;j++){
            if(a[i]==b[j]){
                if(dp[i-1][j]+1<dp[i-1][j-1]){
                    dp[i][j] = dp[i-1][j]+1;
                    last[i][j] = {i-1,j,1};
                }else{
                    dp[i][j] = dp[i-1][j-1];
                    last[i][j] = {i-1,j-1,0};
                }
            }
            else{
                dp[i][j] = dp[i-1][j];
                last[i][j] = {i-1,j,0};
            }
        }
    }
    cout<<dp[n][m]<<endl;
    ll x = n,y = m;
    string ans = "";
    while(x!=0){
        if(last[x][y].da) ans.pb('*');
        else ans.pb(s[x-1]);
        lasti p = last[x][y];
        x = p.i;
        y = p.j;
    }
    reverse(all(ans));
    cout<<ans<<endl;
	return 0;
}
//if(a[i]==b[j]) dp[i][j] = min(dp[i][j-1]+1,dp[i-1][j-1]);
            //else dp[i][j] = dp[i-1][j];