#include <bits/stdc++.h>

using namespace std;

void ispis(string str, string X)
{
	int N = str.size();
	int M = X.size();
	int dpp[N][M] = {};
    char C;
    int m = N + 1;

	for (int j = 0; j < M; j++) {
		if (str[0] == X[j]) {
			dpp[0][j] = 1;
		}
	}

	for (int i = 1; i < N; i++) {

		for (int j = 0; j < M; j++) {
			if (str[i] == X[j]) {
				dpp[i][j] = dpp[i - 1][j] + 1;
			}
			else {
				dpp[i][j] = dpp[i - 1][j];
			}
		}
	}

    for (int j = 0; j < M; j++){
        if (dpp[N - 1][j] < m) {
            m = dpp[N - 1][j];
            C = X[j];
        }
    }

	cout << m << endl;
	for (int i = 0; i < str.length(); i++)
        if (str[i] == C)
            str[i] = '*';
	cout << str;
}

int main()
{
	string str, X;
	cin >> str;
	cin >> X;
	ispis(str, X);
	return 0;
}