#include <iostream>
#include <string>
#include <vector>
#include <cstring>

using namespace std;

int main()
{
    string t, s;

    getline(cin, t);

    cin >> s;

    int pon[s.length()] = {0};

    bool ind = false;

    for(int j = 0; j < t.length(); j++){

        if(t[j] == s[0]) pon[0]++;
    }

    for(int i = 1; i < s.length(); i++){

        if(t.find(s[i]) == string::npos){

            ind = true;

            break;
        }

        for(int h = 0; h < t.length(); h++){

            if(t[h] == s[i] && h > t.find(s[i-1])) pon[i]++;
        }
    }

    int naj = pon[0];

    int najp = 0;

    if(ind == false){

        for(int g = 1; g < s.length(); g++){

            if(pon[g] < naj){

                naj = pon[g];

                najp = g;
            }
        }

        for(int y = 0; y < naj; y++){

            t.replace(t.rfind(s[najp]), 1, "*");

        }

        cout << naj << endl;;

        cout << t;
    }

    else {

        cout << 0 << endl;

        cout << t;
    }

    return 0;
}