#include <iostream>
#include <string>
#include <algorithm>
#include <map>

using namespace std;

int binsrc(string& s, char src) {
	int l = 0, d = s.size() - 1;
	while (l <= d) {
		int median = l + (d - l) / 2;
		if (s[median] == src)
			return median;
		else if (s[median] > src)
			d = median - 1;
		else
			l = median + 1;
	}
	return -1;
}

int main() {
	string maintext; 
	cin >> maintext;
	int i;
	map<char, int> count;
	for (i = 0; i < maintext.size(); i++)
		count[maintext[i]]++;
	string forbidden;
	cin >> forbidden;
	sort(forbidden.begin(), forbidden.end());
	map<char, int>::iterator itr;
	int min = 200001;
	int index2 = -1;
	for (itr = count.begin(); itr != count.end(); itr++) {
		int index1 = binsrc(forbidden, itr->first);
		if (index1 != -1)
			if (itr->second < min) {
				min = itr->second;
				index2 = index1;
			}
	}
	cout << min << "\n";
	for (i = 0; i < maintext.size(); i++) {
		if (maintext[i] != forbidden[index2])
			cout << maintext[i];
		else
			cout << "*";
	}
	cout << "\n";

	return 0;
}