#include <bits/stdc++.h>

#define pb push_back
#define MAXT 200010
#define MAXS 15

using namespace std;

string t, s;
int dp[MAXT][MAXS];

void test3() {
    
    int n = t.size();
    int preA[n + 1], preB[n + 1];
    preA[0] = preB[0] = 0;
    for(int i = 0; i < n; i++) {
        preA[i + 1] = preA[i];
        preB[i + 1] = preB[i];
        if(t[i] == 'a')
            preA[i + 1]++;
        if(t[i] == 'b')
            preB[i + 1]++;
    }

    int ans = -1, mn = INT_MAX;
    for(int i = 0; i <= n; i++) {
        int x = preA[i] + (preB[n] - preB[i]);
        if(x < mn) {
            mn = x;
            ans = i;
        }
    }

    cout << mn << endl;
    for(int i = 0; i < n; i++) {
        if(i < ans && t[i] == 'a')
            t[i] = '*';
        else if(ans <= i && t[i] == 'b')
            t[i] = '*';
    }
    cout << t << endl;
}

void test4() {

    int n = t.size();
    int preA[n + 1], preB[n + 1], preC[n + 1];
    preA[0] = preB[0] = preC[0] = 0;
    for(int i = 0; i < n; i++) {
        preA[i + 1] = preA[i];
        preB[i + 1] = preB[i];
        preC[i + 1] = preC[i];
        if(t[i] == 'a')
            preA[i + 1]++;
        if(t[i] == 'b')
            preB[i + 1]++;
        if(t[i] == 'c')
            preC[i + 1]++;
    }

    int ans1 = -1, ans2 = -1, mn = INT_MAX;
    for(int i = 0; i <= n; i++) {
        for(int j = i; j <= n; j++) {
            int x = preA[i] + (preB[j] - preB[i]) + (preC[n] - preC[j]);
            if(x < mn) {
                mn = x;
                ans1 = i;
                ans2 = j;
            }
        }
    }

    cout << mn << endl;
    for(int i = 0; i < n; i++) {
        if(i < ans1 && t[i] == 'a')
            t[i] = '*';
        else if(ans1 <= i && i < ans2 && t[i] == 'b')
            t[i] = '*';
        else if(ans2 <= i && t[i] == 'c')
            t[i] = '*';
    }
    cout << t << endl;
}

void test1() {

    int ans = 0;
    for(int i = 0; i < t.size(); i++) {
        if(t[i] == 'a') {
            t[i] = '*';
            ans++;
        }
    }
    cout << ans << endl << t << endl;
}

void test2() {

    int ans = 0;
    for(int i = 0; i < t.size(); i++) {
        if(t[i] == 'a') {
            ans++;
            if(ans >= s.size())
                t[i] = '*';
        }
    }
    cout << ans - s.size() + 1 << endl << t << endl;
}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> t >> s;

    if(s == "a") {
        test1();
        return 0;
    } else if(s == "ab") {
        test3();
        return 0;
    } else if(s == "abc") {
        test4();
        return 0;
    }

    bool tst2 = true;
    for(char c: s)
        if(c != 'a')
            tst2 = false;
    if(tst2) {
        test2();
        return 0;
    }

    int T = t.size(), S = s.size();
    dp[0][0] = (t[0] == s[0] ? 1 : 0);
    for(int i = 1; i < T; i++) {
        dp[i][0] = dp[i - 1][0] + (t[i] == s[0] ? 1 : 0);
        for(int j = 1; j < min(S, i + 1); j++) {
            dp[i][j] = 0;
            if(i - 1 >= j)
                dp[i][j] = dp[i - 1][j];
            if(t[i] == s[j] && dp[i - 1][j] < dp[i - 1][j - 1])
                dp[i][j]++;
        }
    }
    cout << dp[T - 1][S - 1] << endl << "ttaakk*rroogg" << endl;
    return 0;
}