#include <bits/stdc++.h>
#define MAXM 12
#define MAXN 200010
using namespace std;

int dp[MAXM][MAXN];

int main()
{
    string a;
    cin >> a;
    string s;
    cin >> s;
    int n = a.size(), m = s.size();
    bool ind = true;
    for(int i = 0; i < m; i++)
    {
        if(s[i] != 'a') ind = false;
    }
    if(ind)
    {
        int br = 0;
        for(int i = 0; i < n; i++)
        {
            if(a[i] == 'a') br++;
        }
        int i = 0;
        cout << br - m + 1 << endl;
        for(int j = 0; i < n && j < br - m + 1; i++)
        {
            if(a[i] == 'a') {cout << "*";j++;}
            else cout << a[i];
        }
        for(; i < n; i++)
            cout << a[i];
        cout << endl;
        return 0;
    }
    /*else if(s == "ab")
    {

    }*/
    else
    {
        a = " " + a;
        s = " " + s;
        for(int i = 1; i <= n; i++)
        {
            dp[1][i] = dp[1][i-1];
            if(a[i] == s[1]) dp[1][i]++;
        }
        for(int i = 2; i <= m; i++)
        {
            int prev = 0;
            bool sel = false; /// da li je prev selected
            for(int j = 1; j <= n; j++)
            {
                dp[i][j] = dp[i][j-1];
                if(a[j] == s[i])
                {
                    if(!sel)
                    {
                        ///cout << "x" << prev << "x";
                        if(dp[i-1][j-1/** j */] - dp[i-1][prev] > 0)
                        {
                            prev = j;
                            dp[i][j]++;
                        }
                        if(dp[i-1][j-1] - dp[i][j-1] > 1) /// !!!! ovo se nikad nece desiti ako se ne desi ovaj if iznad? !!!!
                        {
                            sel = true;
                        }
                    }
                    else
                    {
                        dp[i][j]++;
                        if(dp[i-1][j-1] - dp[i][j-1] <= 1)
                        {
                            sel = false;
                        }
                        prev = j;
                    }
                }
                ///cout << dp[i][j] << " ";
            } ///cout << endl;
        } ///cout << endl;

        /**for(int i = 1; i <= m; i++){
            for(int j = 1; j <= n; j++)
                cout << dp[i][j] << " ";
            cout << endl;
        }*/


        cout << dp[m][n] << endl;
    }

    return 0;
}

/**

aababababbaaabbba
aaa

abababaa
aaa

abbaaabaabbbbbab
ab
7

aaabaabbbba
ab
5

baaadd
baad



*/