#include<bits/stdc++.h>

using namespace std;

void sveJeA(string a, string b){
    long long limit = b.size();
    long long bra = 0;
    for(long long i = 0 ; i < a.size() ; i++){
        if(a[i] == 'a'){
            bra++;
            if(limit <= bra) a[i] = '*';
        }
    }
    if(bra - limit + 1 < 0) cout << 0 << endl;
    else cout << bra - limit + 1 << endl;
    cout << a;
}

int main(){
    string a, b;
    cin >> a >> b;
    long long n = a.size(), m = b.size();
    bool sveA = true;
    for(long long i = 0 ; i < m ; i++){
        if(b[i] != 'a'){
            sveA = false;
        }
    }
    if(sveA == true){
        sveJeA(a, b);
        return 0;
    }
    long long dp[m + 1][n + 1];
    vector<long long> p(m, 0);
    for(long long i = 0 ; i <= m ; i++){
        dp[i][0] = 0;
    }
    for(long long j = 0 ; j <= n ; j++){
        dp[0][j] = j;
    }
    for(long long i = 1 ; i <= m ; i++){
        for(long long j = 1 ; j <= n ; j++){
            if(a[j - 1] == b[i - 1]) p[i - 1]++;
            if(dp[i - 1][j] < dp[i][j - 1] + p[i - 1]){
                dp[i][j] = dp[i - 1][j];
            }
            else{
                dp[i][j] = dp[i][j - 1] + p[i - 1];
                p[i - 1] = 0;
            }
        }
    }
    cout << dp[m][n];
    return 0;
}