#include <iostream>
#include <vector>
#include <numeric>
#include <sstream>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <cmath>
#include <iterator>
#include <map>
#include <climits>
#define watch(x) cout << (#x) << " is " << (x) << endl

using namespace std;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string t, s;
	cin>>t>>s;
	int n = t.size();
	int m = s.size();
	int ss = 1;
	for(int i = 0; i < m-1; i++)
    {
        //watch(s[i]);
        //watch(s[i+1]);
        if(s[i+1] != s[i])
        {
            ss = 0;
            //watch(ss);
        }
    }

	//Prvi podzadatak
	if(m == 1)
    {
        int r = 0;
        for(int i = 0; i < n; ++i)
        {
            if(s[0] == t[i])
            {
                t[i] = '*';
                r++;
            }
        }
        cout<<r<<"\n"<<t;
    }
    else if(ss = 1) //Drugi podzadatak
    {
        int r = 0;
        int x = m-1;
        for(int i = 0; i < n; ++i)
        {
            if(s[0] == t[i])
            {
               if(x>0)
                    x--;
               else
               {
                   t[i] = '*';
                   r++;
               }
            }
        }
        cout<<r<<"\n"<<t;
    }
    else if(m == 2)//Treci podzadatak
    {
        int pa=0; int pb=0; int r;
        int N0, N1;
        for(int i = 0; i < n; ++i)
        {
            if(s[0] == t[i])
                N0++;
            else if(s[1] == t[i])
                N1++;
        }
        for(int i = 0; i < n; ++i)
        {
            if(s[1] == t[i] && pa == 0)
                N1--;
            else if(s[0] == t[i])
                pa++;
        }
        for(int i = 0; i < n-1; ++i)
        {
            if(s[0] == t[n-i] && pb == 0)
                N0--;
            else if(s[1] == t[n-i])
                pb++;
        }

        if(N0 > N1)
        {
            r = N0;
            for(int i = 0; i < n; ++i)
            {
                if(s[0] == t[i] && N0>0)
                {
                    t[i] = '*';
                    N0--;
                }
            }
        }
        else
        {
            r = N1;
            for(int i = 0; i < n-1; ++i)
            {
                if(s[1] == t[n-i] && N1 > 0)
                {
                    t[i] = '*';
                    N1--;
                }
            }
        }
        //watch(t[0]);
        cout<<r<<"\n"<<t;
    }
}