#include<bits/stdc++.h>
using namespace std;

int main(){
	string s, t;
	int counter = 0;
	string p;
	cin>>t>>s;
	int f = s.length();
	int e = t.length();
	int a[1001], b[1001];
	string x1 = "abcdefghijklmnopqrstuvwxyz";
	for(int i = 0; not(i >= f); i++){
		a[i] = count(t.begin(), t.end(), s[i]);
		b[i] = a[i];
	}
	if (1==1){
		sort(a, a + f);
	}
	int slovo = a[0];
	for(int i = 0; i < 100001; i++){
		if(slovo == b[i]){
			p = s[i];
			break;
		}
	}
	for(int i = 0; i < e; i++){
		if( t[i] == p[0]){
			counter++;
		}
	}
	cout<<counter<<endl;
	for(int i = 0; i < e; i++){
		if(t[i] == p[0]){
			cout<<"*";
		}
		else cout<<t[i];
	}
	return 0;
}