#include<stdio.h>
#include<iostream>
#include<string>
#include<math.h>
using namespace std;
int main() {
	string s, t;
	getline(cin, t);
	cin >> s;
	int si[10], i, j;
	int p = t.find_first_of(s[0]), k = t.find_last_of(s[s.length()-1]);
	for (i = 0; i < s.length(); i++) {
		si[i] = 0;
	}
	string t1 = "";
	for (i = p; i < k + 1; i++) {
		t1 += t[i];
	}
	for (i = 0; i < t1.length(); i++) {
		for (j = 0; j < s.length(); j++) {
			if (t1[i] == s[j]) {
				si[j]++;
				break;
			}
		}
	}
	int mini, min=0;
	for (i = 0; i < s.length(); i++) {
		if (min >= si[i]) {
			min = si[i];
			mini = i;
		}
	}
	char c = s[mini];
	int br = 0;
	for (i = 0; i < t.length(); i++) {
		if (t[i] == c)br++;
	}
	printf("%d\n", br);
	for (i = 0; i < t.length(); i++) {
		if (t[i] == c)printf("*");
		printf("%c", t[i]);
	}
}