#include <iostream>
#include <vector>

using namespace std;

int main()
{
    string tekst, rec;
    cin >> tekst >> rec;
    vector<int> reci[tekst.length()];
    vector<int> slova[rec.length()-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) for(int z = 0; z < slova[y-1].size(); z++) reci[slova[y-1].at(z)].push_back(i);
                if(y < rec.length()-1) slova[y].push_back(i);
            }
        }
    }

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

    cout << minPov << endl;
    for(int i = 0; i < minPov; i++) tekst[reci[index].at(i)] = '*';
    cout << tekst;
}