#include <iostream>

using namespace std;

int main()
{
    bool ind = false;
    bool ind2 = false;
    int br = 0, x, br2 = 0, br3 = 0;
    string t,s;
    cin >> t >> s;
    if(s != "ab"){
        for (int i = 0; i < t.size(); i++){
            if(t[i] == 'a')br++;
        }
        x = s.size();
        if(br >= x){
            for (int i = 0; i < t.size(); i++){
                if(t[i] == 'a'){
                    t[i] = '*';
                    x += 1;
                }
                if(br - x == -1)
                    break;
            }
            cout << x - s.size() << endl;
            cout << t << endl;
        }
        else
            cout << 0;
    }
    else{
        for (int i = 0; i < t.size(); i++){
            if(t[i] == 'a'){
                br++;
                ind = true;
            }
            else if(t[i] == 'b' && ind){
                br2++;

            }
        }
        if(br2 < br){
            ind = false;
            for (int i = 0; i < t.size(); i++){
                if(t[i] == 'a'){
                    ind = true;
                }
                else if(t[i] == 'b' && ind){
                    t[i] = '*';
                    br3++;
                }
            }
        }
        else if(br != 0){
            for (int i = 0; i < t.size(); i++){
                if(t[i] == 'a' && br2 > 0){
                    t[i] = '*';
                    br3++;
                }
                else if(t[i] == 'b'){
                    br2--;
                }
            }
        }
        cout<< br3 << endl;
        cout << t;
    }



    return 0;
}