#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char** argv) {
	string s1, s2;
	cin >> s1 >> s2;
	vector<tuple<char, int, int> > a;
	int j = 0;
	a.push_back(make_tuple(s1[0], 1, 0));
	for(int i = 1; i < s1.size(); i++) {
		if(s1[i] == get<0>(a[j]))	get<1>(a[j])++;
		else {
			a.push_back(make_tuple(s1[i], 1, i));
			j++;
		}		
	}
	int min = 0;
	vector<int> k;
	for(int i = 0; i < a.size(); i++){
		if(get<0>(a[i]) == s2[0]) {
			int tmin = INT_MAX, tk = i;
			bool b = true;
			for(j = 0; j < s2.size(); j++){
				if(get<0>(a[i+j]) == s2[j]){
					if(get<1>(a[i+j]) < tmin) 
					{
						tmin = get<1>(a[i+j]);
						tk = get<2>(a[i+j]);
					}
				}
				else { b = false; break;}
			}
			if(b) {
				min += tmin;
				k.push_back(tk);
			}
		}
	}
	for(int i = 0; i < k.size(); i++) {
		char c = s1[k[i]];
		while(true) {
			if(s1[k[i]] == c)
				s1[k[i]] = '*';
			else break;
			k[i]++;
		}
	}
	printf("%d\n", min);
	cout << s1;
	return 0;
}