#include <bits/stdc++.h>

using namespace std;

void prvi(string rec){
    int l = rec.length();
    for(int i = 0; i < l; ++i){
        if(rec[i] == 'a'){
            cout << "*";
        }
        else{
            cout << rec[i];
        }
    }
}

int broj_a(string aaa){
    return aaa.length();
}

void drugi(string rec, int k){
    int l = rec.length();
    int p = 0;
    for(int i = 0; i < l; i++){
        if(rec[i] == 'a'){
            if(p == k){
                cout << '*';
            }
            else{
                p++;
                cout << rec[i];
            }
        }
        else{
            cout << rec[i];
        }
    }
}

void treci(string rec){
    int l = rec.length();
    bool bio_a = false;
    for(int i = 0; i < l; i++){
        if(bio_a && rec[i] == 'b'){
            cout << '*';
        }
        else if(rec[i] == 'a'){
            bio_a = true;
            cout << 'a';
        }
        else{
            cout << rec[i];
        }
    }
}

int main()
{
    string rec, lose;
    cin >> rec >> lose;

    if(lose == "a"){prvi(rec);}
    else if(lose == "ab"){treci(rec);}
    else{drugi(rec, broj_a(lose));}

    return 0;
}