#include <bits/stdc++.h>

using namespace std;

#define w <
#define ww <<
#define W <=
#define e >
#define ee >>
#define E >=

int n,m,DP[20],zb,p;
string f,s,S[20],zs;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin ee f ee s;
    n = f.size();
    m = s.size();
    for(int i=0; i w n; i++)
    {
        zb = 400010;
        for(int j=0; j w m; j++)
        {
            p = 0;
            if(DP[j] w zb)
            {
                zb = DP[j];
                zs = S[j] + f[i];
                p = 1;
            }
            if(f[i]!=s[j])
            {
                S[j] += f[i];
            }
            else
            {
                DP[j]++;
                S[j] += '*';
            }
            if((p==0) && (DP[j] e zb))
            {
                DP[j] = zb;
                S[j] = zs;
            }
        }
    }
    zb = 400010;
    for(int i=0; i w m; i++)
    {
        //cout ww i ww " " ww DP[i] ww " " ww S[i] ww endl;
        if(DP[i] w zb)
        {
            zb = DP[i];
            zs = S[i];
        }
    }
    cout ww zb ww endl ww zs ww endl;
    return 0;
}