#include<bits/stdc++.h>

using namespace std;

void FICA()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    string t;
    string s;
    int brojac = 0;

    cin>>t;
    cin>>s;

    if(s == "a"){
        for(int i=0; i<t.length() ; ++i){
            if(t[i] == 'a') {
                    t[i] = '*';
                    brojac++;
                    }
        }

        cout<<brojac<<endl<<t<<endl;
        return;

    }else if(s == "ab"){

           bool p = false;
           for(int i=0; i<t.length() ; ++i){

            if(p && t[i] == 'b'){
                t[i] = '*';
                brojac++;
                p = false;
            }else{

            if(t[i] == 'a')
                p = true;
            }

           }

           cout<<brojac<<endl<<t<<endl;

        }else {

    int p = s.length() - 1;

     for(int i=0; i<t.length() ; ++i){
            if(t[i] == 'a') {
                    if(p == 0)
                    {
                    t[i] = '*';
                    brojac++;
                    p = s.length() - 1;
                    }
                    else{
                        p--;
                        }
            }
        }

        cout<<brojac<<endl<<t<<endl;
        return;
    }

}

int main(void)
{
    FICA();
    return 0;
}