#include <bits/stdc++.h>

using namespace std;

int dp[200000][10];
pair<int, int> par[200000][10];
string t, s;

int dprog(int n, int m)
{

    for (int i = 0; i < m; ++i) {if (t[0] == s[i]) {dp[0][i] = 1; par[0][i] = {-1, -1};}}

    for (int i = 1; i < n; ++i) {
        for (int j = 0; j < m; ++j) {

            if (t[i] != s[j]) {dp[i][j] = dp[i-1][j]; par[i][j] = {i-1, j};}
            else {

                if (j > 0) {

                    if (dp[i-1][j] + 1 <= dp[i-1][j-1]) {

                        dp[i][j] = dp[i-1][j] + 1;
                        par[i][j] = {i-1, j};
                    }

                    else {
                        dp[i][j] = dp[i-1][j-1];
                        par[i][j] = {i-1, j-1};
                    }

                }

                else {dp[i][j]=dp[i-1][j]+1;par[i][j]={i-1, j};}

            }

        }

    }

    return dp[n-1][m-1];

}

void ispis(int n, int m, int sol) {

    if (n >= 0 && m >= 0 && sol > 0) {
    pair<int, int> p = par[n][m];
    int dpprev;
    if (p.first < 0) dpprev = 0;
    else dpprev = dp[p.first][p.second];
    int dpcurr = dp[n][m];
    if (dpprev != dpcurr) {t[n] = '*';sol--;}//printf("%d\n", n);
    ispis(p.first, p.second, sol);
    }

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> t >> s;

    int n = t.size();
    int m = s.size();

    int sol = dprog(n,m);
    cout << sol << '\n';
    /*for (int i = 0; i < n; ++i) {

        for (int j = 0; j < m; ++j) {

            pair<int, int> p = par[i][j];
            //printf("%d %d   ", p.first, p.second);
            printf("%d ", dp[i][j]);

        }
        printf("\n");

    }*/
    ispis(n-1, m-1, sol);
    cout << t << '\n';

    return 0;
}