#include <iostream>
#include <string>

using namespace std;

#define MAX_ZABRANJENA 10
#define MIN_ZABRANJENA 1
#define MAX_TEKST      200000
#define MIN_TEKST      1

bool pronadji(string &tekst, string &rec, int* counter, bool zameni=false, int min_ch=-1){
    size_t previous_loc = -1;
    size_t current_loc = -1;

    int slovo = 0;

    bool first = true;
    bool uspesno = false;

    while(true){

        if(!first){
            current_loc = tekst.find(char(rec[slovo - 1]), previous_loc + 1);
            if(current_loc != string::npos){
                previous_loc = current_loc;
                if(!zameni) counter[slovo - 1]++;
                else{
                    if(slovo == min_ch + 1){
                        tekst.replace(previous_loc, 1, "*");
                    }
                }
            }else{
                if(slovo < int(rec.size())){
                    current_loc = tekst.find(rec[slovo], previous_loc + 1);
                    if(current_loc != string::npos){
                        previous_loc = current_loc;
                        if(!zameni) counter[slovo]++;
                        else{
                            if(slovo == min_ch){
                                tekst.replace(previous_loc, 1, "*");
                            }
                        }

                        if(slovo != int(rec.size())){
                            slovo++;
                        }
                    }else{
                        uspesno = false;
                        break;
                    }
                }else{
                    uspesno = true;
                    break;
                }
            }
        }else{
            current_loc = tekst.find(char(rec[slovo]), previous_loc + 1);
            if(current_loc == string::npos){
                break;
            }
            previous_loc = current_loc;
            if(!zameni) counter[slovo]++;
            else{
                if(slovo == min_ch){
                    tekst.replace(previous_loc, 1, "*");
                }
            }
            slovo++;
            first = false;
        }

    }

    return uspesno;
}

int main()
{
    string tekst;
    string rec;

    getline(cin, tekst);
    while(true)
    {
        bool uspesno = false;

        char counter = 1;
        size_t found = -1;
        while(true)
        {
            found  = tekst.find(' ', found + 1);
            if(found != string::npos)
            {
                counter++;
            }
            else
            {
                break;
            }
        }

        if(counter == 1)
        {
            if(tekst.size() >= MIN_TEKST && tekst.size() <= MAX_TEKST){
                uspesno = true;
            }

        }else
        {
            uspesno = false;
        }

        if(!uspesno){
            cout << "Pogresan unos, pokusaj opet: ";
            getline(cin, tekst);
        }else{
            break;
        }
    }

    getline(cin, rec);
    while(true)
    {
        bool uspesno = false;

        char counter = 1;
        size_t found = -1;
        while(true)
        {
            found  = rec.find(' ', found + 1);
            if(found != string::npos)
            {
                counter++;
            }
            else
            {
                break;
            }
        }

        if(counter == 1)
        {
            if(rec.size() >= MIN_ZABRANJENA && rec.size() <= MAX_ZABRANJENA){
                uspesno = true;
            }

        }else
        {
            uspesno = false;
        }

        if(!uspesno){
            cout << "Pogresan unos, pokusaj opet: ";
            getline(cin, rec);
        }else{
            break;
        }
    }

    int counter[rec.size()];

    for(int i = 0; i < int(rec.size()); i++){
        counter[i] = 0;
    }

    bool uspesno = pronadji(tekst, rec, counter);

    if(!uspesno){
        cout << "ne postoji zabranjena rec";
    }else{
        int min_num = counter[0];
        int min_ch = 0;

        for(int i = 1; i < int(rec.size()); i++){
            if(counter[i] < min_num) {
                    min_num = counter[i];
                    min_ch = i;
            }
        }

        pronadji(tekst, rec, counter, true, min_ch);
        cout << endl << tekst;

    }

    return 0;
}