#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
void empty(int the[]){
	int i=26;
	while(i--)
		the[i+1]=0;
	the[0]=0;
}
int main(){
	string s,t;
	int m,n;
	cin >> t >> s;
	m=s.size();
	n=t.size();
	static int the[26];
	static int them[26];
	for(int i=0; i < m; i++)
		them[(int)s[i]-97]++;
	int themin=0,sdfsd=0,f=0,doing=0;
	while(!f)
	for(int i=0,j=0; i <= n; i++){
		if(j+1<m && t[i+1]==s[j+1] && doing) sdfsd=1;
		if(i<n && t[i]==s[j]){
			the[(int)t[i]-97]++;doing=1;
			if(j+1<m && t[i+1]==s[j+1] && doing) sdfsd=1;
		}
		else if(j!=m-1){empty(the);j=0;doing=0;}
		else if(j==m-1){
			int mini,minx=200000;
			for(int g = 0; g < 26; g++)
				if(the[g] < minx && the[g] != 0){
					minx=the[g];
					mini=g+97;
				}
			themin+=minx;
			for(int e = i-1; minx; e--){ 
				if(t[e]==(char)mini){
					t[e]='*';
					minx--;
				}

			}
			empty(the);
			j=0;
			doing=0;
			break;
		}
		if(sdfsd){j++;sdfsd=0;}
		if(i==n)f=1;
	}
	cout << themin << "\n" << t << "\n";
}