#include <bits/stdc++.h>
using namespace std;
int main()
{
    string T, S;
    int br = 0;
    cin >> T >> S;
    if (S == "a")
    {
        for (int i = 0; i < T.size(); ++i)
        {
            if (T[i] == 'a')
            {
                T[i] = '*';
                br++;
            }
        }
        cout << br << "\n" << T;
    }
    else
    {
        bool flag = true;
        for (int i = 0; i < S.size(); ++i)
        {
            if (S[i] != 'a')
            {
                flag = false;
                break;
            }
        }
        if (flag)
        {
            int l = S.size();
            int p = 0;
            for (int i = 0; i < T.size(); ++i) if (T[i] == 'a') p++;
            br = p - l;
            int r = br;
            if (br == 0) cout << br << "\n" << T;
            else for (int i = 0; i < T.size(); ++i) if (T[i] == 'a')
            {
                T[i] = '*';
                r--;
                if (r == 0)
                {
                    cout << br << "\n" << T;
                    break;
                }
            }
        }
        else if (S == "ab")
        {
            int A = 0, B = 0, index, BL, AD, maks = 0;
            for (int i = 0; i < T.size(); ++i)
            {
                if (T[i] == 'a') A++;
                else if (T[i] == 'b') B++;
            }
            index = -1;
            BL = 0;
            AD = A;
            maks = BL + AD;
            for (int i = 0; i < T.size(); ++i)
            {
                if (T[i] == 'a') AD--;
                else if (T[i] == 'b')
                {
                    BL++;
                    if (BL + AD > maks)
                    {
                        maks = BL + AD;
                        index = i;
                    }
                }
            }
            for (int i = 0; i <= index; ++i) if (T[i] == 'a') T[i] = '*';
            for (int i = index + 1; i < T.size(); ++i) if (T[i] == 'b') T[i] = '*';
            cout << A + B - maks << "\n" << T;
        }
    }
}