#include <bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    string t, s; cin >> t >> s;
    int n = t.size(), m = s.size();
    t = " " + t; s = " " + s;
    vector<vector<int>> dp(n + 2, vector<int>(m + 2));
    vector<vector<int>> ds(n + 2, vector<int>(m + 2));
    for (int i = 0; i < n + 2; i++) {
        dp[i][0] = ds[i][m + 1] = 1;
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            dp[i][j] |= dp[i - 1][j];
            dp[i][j] |= ((t[i] == s[j]) && dp[i - 1][j - 1]);
        }
    }
    for (int i = n; i >= 1; i--) {
        for (int j = m; j >= 1; j--) {
            ds[i][j] |= ds[i + 1][j];
            ds[i][j] |= ((t[i] == s[j]) && ds[i + 1][j + 1]);
        }
    }
    int r = n + 1, w;
    for (int j = 1; j <= m; j++) {
        int c = 0;
        for (int i = 1; i <= n; i++) {
            c += (t[i] == s[j] && dp[i][j] && ds[i][j]);
        }
        if (c < r) {
            r = c; w = j;
        }
    }
    cout << r << endl;
    for (int i = 1; i <= n; i++) {
        if (t[i] == s[w] && dp[i][w] && ds[i][w]) {
            cout << "*"; continue;
        }
        cout << t[i];
    }
    cout << endl;
}