#include <bits/stdc++.h>

using namespace std;

int main()
{
    string s, z;
    cin>>s;
    cin>>z;

    int sL = s.length();
    int zL = z.length();
    int br = 0;

    bool obrisi = false;

    string s1 = "";

    if(zL == 1 && z[0] == 'a')
    {
        for(int i = 0; i < sL; i++)
        {
            if(s[i] == 'a')
            {
                s1.push_back('*');
                br++;
            }
            else s1.push_back(s[i]);
        }
    }
    else if(zL == 2 && z[0] == 'a' && z[1] == 'b')
    {
        br = 0;
        for(int i = 0; i < sL; i++)
        {
            obrisi = false;
            if(s[i] == 'a')
            {
                for(int j = i+1; j < sL; j++) if(s[j] == 'b') obrisi = true;
                if(obrisi)
                {
                    s1.push_back('*');
                    br++;
                }
                else s1.push_back(s[i]);
            }
            else s1.push_back(s[i]);
        }
    }
    else
    {
        int nA = 0;
        for(int i = 0; i < zL; i++)
        {
            if(z[i] == 'a') nA++;
        }

        int nA1 = 0;
        for(int i = 0; i < sL; i++)
        {
            if(s[i] == 'a') nA1++;
        }

        int nAS = nA1;

        if(nA == zL)
        {
            for(int i = 0; i < sL; i++)
            {
                if(s[i] == 'a' && nA1 >= nA)
                {
                    s1.push_back('*');
                    nA1--;
                }
                else s1.push_back(s[i]);
            }
        }

        br = nAS-nA1;
    }


    cout<<br<<endl;
    cout<<s1;

    return 0;
}