#include <iostream>

using namespace std;

int main()
{
    string t, s;
    cin >> t >> s;
    if(s == "a")
    {
        int rez = 0;
        for(int i = 0; i < (int)t.size(); i++)
        {
            if(t[i] == 'a')
            {
                t[i] = '*';
                rez++;
            }
        }
        cout << rez << endl;
        cout << t << endl;
    }
    else if(s == "ab")
    {
        int a = 0, b = 0;
        bool imaA = false;
        for(int i = 0; i < (int)t.size(); i++)
        {
            if(t[i] == 'a')
            {
                imaA = true;
                a++;
            }
            if(t[i] == 'b' && imaA)
            {
                b++;
            }
        }
        if(a < b)
        {
            for(int i = 0; i < (int)t.size(); i++)
            {
                if(t[i] == 'a')
                    t[i] = '*';
            }
            cout << a << endl;
            cout << t << endl;
        }
        else
        {
            int b2 = b;
            for(int i = (int)t.size() - 1; i >= 0; i--)
            {
                if(t[i] == 'b' && b2 > 0)
                {
                    t[i] = '*';
                    b2--;
                }
            }
            cout << b << endl;
            cout << t << endl;
        }
    }
    else if(s == "abc")
    {
        int a = 0, b = 0, c = 0;
        bool imaA = false, imaB = false;
        for(int i = 0; i < (int)t.size(); i++)
        {
            if(t[i] == 'a')
            {
                imaA = true;
                a++;
            }
            if(t[i] == 'b' && imaA)
            {
                imaB = true;
                b++;
            }
            if(t[i] == 'c' && imaA && imaB)
            {
                c++;
            }
        }
        if(a <= b && a <= c)
        {
            int a2 = a;
            for(int i = (int)t.size() - 1; i >= 0; i--)
            {
                if(t[i] == 'a' && a2 > 0)
                {
                    t[i] = '*';
                    a2--;
                }
            }
            cout << a << endl;
            cout << t << endl;
        }
        else if(b <= a && b <= c)
        {
            int b2 = b;
            for(int i = (int)t.size() - 1; i >= 0; i--)
            {
                if(t[i] == 'b' && b2 > 0)
                {
                    t[i] = '*';
                    b2--;
                }
            }
            cout << b << endl;
            cout << t << endl;
        }
        else
        {
            int c2 = c;
            for(int i = (int)t.size() - 1; i >= 0; i--)
            {
                if(t[i] == 'c' && c2 > 0)
                {
                    t[i] = '*';
                    c2--;
                }
            }
            cout << c << endl;
            cout << t << endl;
        }
    }
    else
    {
        int a = 0;
        for(int i = 0; i < (int)t.size(); i++)
        {
            if(t[i] == 'a')
            {
                a++;
            }
        }
        int x = a - s.size();
        for(int i = 0; i < (int)t.size(); i++)
        {
            if(t[i] == 'a'  && x >= 0)
            {
                t[i] = '*';
                x--;
            }
        }
        cout << a - s.size() + 1 << endl;
        cout << t << endl;
    }
    return 0;
}