#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define fi first
#define se second
#define ld long double
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) begin(a),end(a)
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<ld, null_type,less<ld>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key -> # less than k
// find_by_order -> k-th element
// pq max element

const double eps = 0.000001;
const int modi = 1e9+7;
const int NMAX = 200010;
void solve() {
    string t,s;
    cin >> t;
    cin >> s;
    int aaaaaaaaaa = 1;
    for (int i = 0 ; i < s.length() ; i++ ) {
        if (s[i] != 'a' ) aaaaaaaaaa = 0;
    }
    if ( aaaaaaaaaa ) {
        int k = s.length()-1;
        int cnt = 0;
        for (int i = 0 ; i < t.length() ; i++ ) {
            if ( t[i] == 'a' ){
                if ( !k ) {
                    t[i] = '*';
                    cnt++;
                }
                else {
                    k--;
                }
            } 
        }
        cout << cnt << endl ;
        cout << t << endl ;
        return;
    }
    if ( s == "ab" ) {
        int n = t.length();
        vector<int>a(n+1);
        vector<int>b(n+1);
        a[0] = b[0] = 0;
        for (int i = 0 ; i < n ; i++ ) {
            a[i+1] = a[i];
            b[i+1] = b[i];
            if ( t[i] == 'a' ){
                a[i+1]++;
            }
            else if ( t[i] == 'b' ) {
                b[i+1]++;
            }
            //cout << a[i+1] << ' ' << b[i+1] << endl ;
        }
        int mini = 10000000;
        int ind = 0;
        for (int i = 0 ; i <= n ; i++ ) {
            int kolikoa = a[i];
            int kolikob = b[n]-b[i];
            if ( kolikob + kolikoa < mini ) {
                mini = kolikob + kolikoa;
                ind = i;
            }
        }
        cout << mini << endl ;
        for (int i = 0 ; i < n ; i++ ) {
            if ( i < ind ) {
                if ( t[i] == 'a' ) {
                    t[i] = '*';
                }
            }
            else {
                if ( t[i] == 'b' ) {
                    t[i] = '*';
                }
            }
        }
        cout << t << endl ;
        return;
    }
}


int main () {
    
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int t = 1;
    
    //cin >>t ;  


    int i = 1 ;
    while(t--) {
        //cout << "Case #" << i++ << ": " ;
        solve(); 
    }
}