#include <bits/stdc++.h>

using namespace std;

string s, t;
int n, m;

void pst() {
	int brojac = 0;
	for(int i = 0; i < n; i++) if(s[i] == 'a') brojac++;
	cout << brojac << "\n";
	for(int i = 0; i < n; i++) {
		if(s[i] == 'a') cout << '*';
		else cout << s[i];
	}
}

void dst() {
	int brojac = 0;
	for(int i = 0; i < n; i++) if(s[i] == 'a') brojac++;
	if(brojac < m) {
		cout << "0\n" << s;
		return;
	}
	cout << brojac-m+1 << "\n";
	for(int i = 0; i < n; i++) {
		if(s[i] == 'a') {
			s[i] = '*';
			brojac--;
			if(brojac < m) break;
		}
	}
	cout << s;
}

void tst() {
	int a[n], b[n];
	a[0] = (s[0] == 'a');
	b[0] = (s[0] == 'b');
	for(int i = 1; i < n; i++) {
		a[i] = a[i-1] + (s[i] == 'a');
		b[i] = b[i-1] + (s[i] == 'b');
	}
	int mn = b[n-1];
	int index = -1;
	for(int i = 0; i < n; i++) {
		if(a[i] + b[n-1] - b[i] < mn) index = i;
		mn = min(mn, a[i] + b[n-1] - b[i]);
	}
	cout << mn << "\n";
	for(int i = 0; i < n; i++) {
		if(s[i] != 'a' && s[i] != 'b') cout << s[i];
		else if(i <= index) {
			if(s[i] != 'b') cout << '*';
			else cout << 'b';
		}
		else {
			if(s[i] != 'a') cout << '*';
			else cout << 'a';
		}
	}
}

void za100() {
	int dp[n][m];
	for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) dp[i][j] = 0;
	if(s[0] == t[0]) dp[0][0] = 1;
	for(int i = 1; i < n; i++) {
		for(int j = 0; j < m; j++) {
			if(s[i] == t[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] << "\n";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> s >> t;
    n = s.size(), m = t.size();
    bool DST = true;
    for(int i = 0; i < m; i++) if(t[i] != 'a') {
    	DST = false;
    	break;
    }
    if(t == "a") pst();
    else if(DST) dst();
    else if(t == "ab") tst();
    else za100();
    return 0;
}