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

int main(){
	
	string recen;
	string cenz;
	getline(cin , recen);
	getline(cin , cenz);
	map<char , int> cenzurisana;
	map<char , int> frek;
	
	for(int i=0;i<cenz.length();i++){
		cenzurisana[cenz[i]] = 1;
	}
	
	for(int i=0;i<recen.length();i++){
		char c = recen[i];
		
		if(cenzurisana.find(c) != cenzurisana.end()){
			frek[c] += 1;
		}
	}
	int mi = 200000;
	char sl = 'a';
	for(map<char,int>::iterator it=frek.begin(); it!=frek.end(); ++it){
		if(mi > it -> second){
			mi = it ->second;
			sl = it -> first;
		}
	}
	string ans = "";
	for(int i=0;i<recen.length();i++){
		if(recen[i] == sl){
			ans += '*';
		}else{
			ans += recen[i];
		}
	}
	cout<<mi<<endl;
	cout<< ans;
	return 0;
}