#include <iostream>
#include <string>
using namespace std;

bool isti(string zabranjena_rec)
{
    int d = zabranjena_rec.length();
    char p = zabranjena_rec[0];
    for (int i = 1; i < d; i++)
    {
        if (zabranjena_rec[i] != p)
        {
            return false;
        }
    }
    return true;
}
int main()
{
    int br = 0;
    string t, s;
    cin >> t >> s;
    int d = t.length();
    if (isti(s))
    {
        int duz = s.length();
        int j = 0;
        for (int i = 0; i < d; i++)
        {
            if (t[i] == s[0] && j != duz)
            {
                j ++;
            }
            //cout << j << endl;
            if (t[i] == s[0] && j == duz)
            {
                br++;
                t[i] = '*';
            }
        }
    }
    else if (s.length() == 2)
    {
        int a = 0, b = 0, z = 0, z2 = 1, pocetak = 0;
        for (int i = 0; i < d; i++)
        {
            if (t[i] == s[0])
            {
                if (z == 1)
                {
                    char p = s[0];
                    if (a > b)
                    {
                        p = s[1];
                    }
                    for (int j = pocetak; j < i; j++)
                    {
                        //cout << j << endl;
                        if (t[j] == p)
                        {
                            br++;
                            t[j] = '*';
                        }
                    }
                    a = 0, b = 0, z = 0;
                    pocetak = i;
                }
                else if (z2 == 1)
                {
                    pocetak = i;
                    z2 = 0;
                }
                if (t[i] == s[0])
                    a++;
            }
            else if (t[i] == s[1] && !z2)
            {
                z = 1;
                b++;
            }
        }
        if (a != 0 && b != 0)
        {
            char p = s[0];
            if (a > b)
            {
                p = s[1];
            }
            for (int j = pocetak; j < d; j++)
            {
                //cout << j << endl;
                if (t[j] == p)
                {
                    br++;
                    t[j] = '*';
                }
            }
        }
    }


    cout << br << endl << t;
    return 0;
}