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

#define ll long long
const int N = 200001, M = 11;
const int inf = 1e9 + 7;
int br1[26], br2[26];
char c[N];

void solve() {
    string t, s;
    int n, m;
    cin >> t >> s;
    n = t.size();
    m = s.size();
    int dp[n + 1][m + 1];
    for (int i = 0; i <= n; i++)
        for (int j = 0; j <= m; j++)
            dp[i][j] = 0;
    for (int i = 0; i < n; i++) {
        br1[t[i] - 'a']++;
        c[i] = t[i];
    }
    for (int i = 0; i < m; i++)
        br2[s[i] - 'a']++;
    if (br2[0] == m) {
        cout << max(br1[0] - br2[0] + 1, 0) << endl;
        return;
    }
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++)
        dp[i][0] = dp[i - 1][0] + 1;
    for (int j = 1; j <= m; j++) {
        for (int i = 1; i <= n; i++) {
            if (t[i - 1] == s[j - 1])
                dp[i][j] = min(dp[i - 1][j - 1], dp[i - 1][j] + 1);
            else
                dp[i][j] = dp[i - 1][j];
        }
    }
    cout << dp[n][m] << endl;
    int i = n, j = m;
    while (i > 0) {
        char c1 = t[i - 1], c2 = s[i - 1];
        if (j == 0)
            break;
        if (t[i - 1] == s[j - 1]) {
            if (dp[i - 1][j] + 1 < dp[i - 1][j - 1]) {
                c[i - 1] = '*';
            }
            else
                j--;
            i--;
            continue;
        }
        i--;
    }
    for (i = 0; i < n; i++) {
        cout << c[i];
    }
    cout << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}