#include <iostream>
#include <vector>
#include <deque>
// #include <set>
#include <algorithm>
#include <cmath>
// #include <queue>

using namespace std;


int dp[200000][10];

int first[10];
int last[10];

int main() {


	string t, s;
    cin >> t;
    cin >> s;

    int nt = t.length();
    int ns = s.length();

    dp[0][0] = (t[0] == s[0]);
    for (int i = 1; i < ns; i++) {
        dp[0][i] = 0;
    }

    for (int i = 1; i < nt; i++) {
        for (int j = 0; j < ns; j++) {
            if (t[i] == s[j]) {
                if (j == 0) {
                    dp[i][j] = dp[i-1][j] + 1;
                } else {
                    if (dp[i-1][j-1] > 0) {
                        dp[i][j] = dp[i-1][j] + dp[i-1][j-1];
                    }
                }
            } else {
                dp[i][j] = dp[i-1][j];
            }
        }
    }


    for (int i = nt-1; i > 0; i--) {
        if (dp[i][ns-1] > dp[i-1][ns-1]) {
            last[ns-1] = i;
            break;
        }
    }

    for (int i = ns-2; i >= 0; i--) {

        int a = -1;
        for (int j = i+1; j < ns; j++) {
            if (s[i] == s[j]) {
                a = last[j];
                break;
            }
        }

        if (a == -1) {
            last[i] = last[i+1] - 1;
        } else {
            last[i] = a;
        }
    }

    for (int i = 0; i < ns; i++) {
        for (int j = 0; j < nt; j++) {
            if (dp[j][i] > 0) {
                first[i] = j;
                break;
            }
        }
    }


    int ind = -1;
    int curr = 0;
    int best = 1000000;

    for (int i = 0; i < ns; i++) {
        for (int j = first[i]; j <= last[i]; j++) {
            if (t[j] == s[i])
                curr++;
        }
        if (curr < best) {
            best = curr;
            ind = i;
        }

        curr = 0;
        //best = min(best, curr);
    }

    //cout << "  " << ind << endl;
    string ans = t;

    for (int i = first[ind]; i <= last[ind]; i++) {
        if (t[i] == s[ind])
            ans[i] = '*';
    }

    cout << best << endl;
    cout << ans << endl;
    

	return 0;
}