#include <iostream>
#include <vector>

using namespace std;

int main()
{
    string tekst, rec;
    cin >> tekst >> rec;
    vector<int> reci[tekst.length()];
    vector<int> reci1;
    int slova[rec.length()-1];
    int slovo1;
    for(int i = 0; i < rec.length()-1; i++) slova[i] = -1;

    for(int i = 0; i < tekst.length(); i++){
        for(int y = 0; y < rec.length(); y++){
            if(tekst[i] == rec[y]) {
                if(y > 0) reci[slova[y-1]].push_back(i);
                else reci1.push_back(i);
                if(y < rec.length()-1) slova[y] = (slova[y] == -1) ? i : slova[y];
                if (y == 1) slovo1 = i;
            }
        }
    }

    int stop;
    for(int i = 0; i < reci1.size(); i++) if (reci1.at(i) > slovo1) {
        stop = i;
        break;
    }

    int minPov = reci1.size() - stop - 1;
    int index = -1;
    for(int i = 0; i < rec.length()-1; i++){
        if(reci[slova[i]].size() < minPov) {
            minPov = reci[slova[i]].size();
            index = slova[i];
        }
    }

    cout << minPov << endl;
    if (index != -1) for(int i = 0; i < minPov; i++) tekst[reci[index].at(i)] = '*';
    else for(int i = 0; i < minPov; i++) tekst[reci1.at(i)] = '*';
    cout << tekst;
}