#include <bits/stdc++.h>
using namespace std;
//acdabfaalasa
int main(){
    int i;
    string t, s;
    cin >> t >> s;

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

    bool drugiPod = true;
    for(i = 0; i < s.length(); i++)
        if(s[i] != 'a'){
            drugiPod = false;
            break;
        }
    if(drugiPod){
        int br = 0;
        for(i = 0; i < t.length(); i++)
            br += t[i] == 'a';
        cout << br << endl;
        if(br < s.length()){
            cout << "0" << endl << t << endl;
            return 0;
        }
        br = br - s.length() + 1;
        i = 0;
        while(br){
            if(t[i] == 'a'){
                t[i] = '*';
                br--;
            }
            i++;
        }
        cout << t << endl;
        return 0;
    }

    if(s == "ab"){

        int lastB = -1;
        for(i = 0; i < t.length(); i++)
            if(t[i] == 'b')
                lastB = i;

        int nA = 0, nB = 0;
        for(i = 0; i <= lastB; i++){
            nA += t[i] == 'a';
            nB += t[i] == 'b';
        }
        cout << min(nA, nB) << endl;
        char c;
        if(nA < nB)
            c = 'a';
        else
            c = 'b';

        for(i = 0; i < lastB; i++)
            if(t[i] == c)
                t[i] = '*';
        cout << t << endl;
        return 0;
    }

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