#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;

bool Podniska(string t, string s)
{
	int i = 0;
	while(i < s.length())
	{
		if(t.length() == 0) return false;
		if(t.length() == 1 && i != s.length() - 1) return false;
		int p;
		if((p = t.find(s[i])) == string::npos) return false;
		t = t.substr(p + 1);
		i++;
	}
	return true;
}

int main()
{
	std::ios_base::sync_with_stdio(false);
	vi slova(26, 0);
	vb predjenaSlova(26, false);
	string t, s;
	cin >> t >> s;
	if(Podniska(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;
		}
		int br = 0;
		char minChar = mini + 'a';
		for(int i = 0; i < t.length(); i++)
		{
			if(!Podniska(t, s)) break;
			if(t[i] == minChar)
			{
				t[i] = '*';
				br++;
			}
		}
		cout << br << endl;
		cout << t << endl;
	}
	else
	{
		cout << "0" << endl;
		cout << t << endl;
	}
}