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

int dp[MAXN][MAXM];

int main()
{
    // Input
    string s;
    cin >> s;
    string ss;
    cin >> ss;
    int n = s.size();
    int m = ss.size();

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



    for(int j = 0; j < m; j++) if(s[0] == ss[j]) dp[0][j] = 1;

    for(int i = 1; i < n; i++)
    {
        for(int j = 0; j < m; j++)
        {
            if (s[i] == ss[j])
            {
                dp[i][j] = dp[i - 1][j] + 1;
                if (j != 0) dp[i][j] = min(dp[i][j], dp[i - 1][j - 1]);
            }
            else dp[i][j] = dp[i - 1][j];
        }
    }
    cout << dp[n - 1][m - 1];

    return 0;
}