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

string t;
string s;
int a;
int characters[15];
int starts[15];
int minA;
int minVal;
bool pass = true;
int sum;

int main()
{
	cin >> t;
	cin >> s;
	while (pass == true){
		a = 0;
		memset(characters, 0, sizeof(characters));
		memset(starts, 0, sizeof(starts));
		for (int i = 0; i < t.size(); ++i)
		{
			if (t[i] == s[a])
			{
				++characters[a];
			}
			else
			{
				if (characters[a] > 0 && a+1 < s.size() && t[i] == s[a+1]){
					a++;
					starts[a] = i;
					if (t[i] == s[a])
					{
						++characters[a];
					}
				}
			}
		}
		if (characters[a] > 0){
			a++;
			starts[a] = t.size();
		}
		if (a < s.size())
		{
			printf("%d\n", sum);
			cout << t << endl;
			return 0;
		}
		//cout << a << endl;
		minA = 0;
		minVal = INT_MAX;
		for (int i = 0; i < a; ++i)
		{
			//cout << "karakter " << s[i] << " - " << characters[i] << endl;
			if (characters[i] < minVal)
			{
				minVal = characters[i];
				minA = i;
			}
		}
		//printf("%d\n", minVal);
		sum += minVal;
		for (int i = starts[minA]; i < starts[minA+1]; ++i)
		{
			if (t[i] == s[minA])
			{
				t[i] = '*';
			}
		}
	}
	//cout << t << endl;
	return 0;
}