#include <bits/stdc++.h>
#define MAXTSIZE 200010
#define MAXSSIZE 11

using namespace std;

typedef long long ll;

ll a[MAXTSIZE][MAXSSIZE];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    string t, s;
    cin >> t >> s;
    ll Nt = (ll)t.size(), Ns = (ll)s.size();

    for(ll i = 1; i <= Nt; i++)
    {
        if(t[i - 1] == s[0])
        {
            a[i][1] = a[i - 1][1] + 1;
        }
        else a[i][1] = a[i - 1][1];
    }

    for(ll i = 2; i <= Ns; i++)
    {
        for(ll j = i; j <= Nt; j++)
        {
            if(t[j - 1] == s[i - 1] && s[i - 1] != s[i - 2])
            {
                a[j][i] = a[j - 1][i] + a[j][i - 1];
            }
            else if(t[j - 1] == s[i - 1])
            {
                a[j][i] = a[j - 1][i] + a[j][i - 1] - 1;
            }
            else
            {
                a[j][i] = a[j - 1][i];
            }
        }
    }


    for(ll i = 1; i <= Ns; i++)
    {
        for(ll j = 1; j <= Nt; j++)
        {
            cout << a[j][i] << " ";
        }
        cout << "\n";
    }


    if(a[Nt][Ns] == 0)
    {
        cout << "0";
        return 0;
    }

    ll lastindex = 0;
    for(int i = 1; i <= Nt; i++)
    {
        if(a[i][Ns] > a[i - 1][Ns]) lastindex = i;
    }

    ll rez, minrez = LLONG_MAX, minrezindex;
    for(ll i = 1; i <= Ns; i++)
    {
        rez = 0;
        for(ll j = 1; j <= lastindex - Ns + i; j++)
        {
            if(a[j][i] > a[j - 1][i]) rez++;
        }
        if(minrez > rez)
        {
            minrez = rez;
            minrezindex = i;
        }
    }
    for(int i = 1; i <= lastindex - Ns + minrezindex; i++)
    {
        if(a[i][minrezindex] > a[i - 1][minrezindex]) t[i - 1] = '*';
    }
    cout << minrez << "\n" << t;
    return 0;
}