#include <iostream>
//#include <fstream>
//#include <iomanip>
//#include <cmath>
//#include <algorithm>
//#include <string>
#include <vector>
//#include <utility>
//#include <map>
//#include <ctime>
//#include <cctype>
//#include <cstdlib>
//#include <limits>
//#include <numeric>
//#include <mycpp.h>

using namespace std;

typedef vector<int> vi;
typedef vector<bool> vb;

int main()
{
	std::ios_base::sync_with_stdio(false);
	vi slova(26, 0);
	vb predjenaSlova(26, false);
	string t, s;
	cin >> t >> s;
	int mini = 0;
	for(int i = 0; i < s.length(); i++)
	{
		int x = s[i] - 'a';
		if(predjenaSlova[x]) continue;
		predjenaSlova[x] = true;
		for(int j = 0; j < t.length(); j++)
			if(t[j] == ((char)(x + 'a')))
				slova[x]++;
		if(slova[x] < slova[mini])
			mini = x;
	}
	char minChar = mini + 'a';
	for(int i = 0; i < t.length(); i++)
		if(t[i] == minChar)
			t[i] = '*';
	cout << slova[mini] << endl;
	cout << t << endl;
}