#include <bits/stdc++.h>
#define ll long long
#define MAXN 200010
using namespace std;
ll a[MAXN][20];
vector<ll> p;
int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    string t,s;
    cin >> t >> s;
    ll n=t.size(),m=s.size();
    t=' '+t;
    s=' '+s;
    for (ll i=1;i<=m;i++)
    {
        if (t[1]==s[i])
            a[1][i]=1;
    }
    for (ll i=2;i<=n;i++)
    {
        for (ll j=1;j<=m;j++)
        {
            if (t[i]==s[j])
            {
                if (j>1)
                {
                    a[i][j]=min(a[i-1][j]+1,a[i-1][j-1]);
                    continue;
                }
                a[i][j]=a[i-1][j]+1;
            }
            else
                a[i][j]=a[i-1][j];
        }
    }
    vector<ll> v;
    ll x=n,y=m;
    while (x!=1)
    {
        if (y<2)
        {
            t[x]='*';
            x--;
            continue;
        }
        if (t[x]==s[y])
        {
            if (y>2 && a[x][y]==a[x-1][y-1])
            {
                x--;
                y--;
                continue;
            }
            t[x]='*';
            x--;
            continue;
        }
        x--;
    }
    cout << a[n][m] << "\n";
    cout << t.substr(1,n) << "\n";
    return 0;
}