#include <bits/stdc++.h>

using namespace std;

int main()
{
    string t, s;

    getline(cin, t);

    cin >> s;

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

    int indikator = false;

    for(int j = 0; j < t.length(); j++){
        if(t[j] == s[0]) n[0]++;
    }

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

        if(t.find(s[i]) == string::npos){
            indikator = true;
            break;
        }

        for(int a = 0; a < t.length(); a++){
            if(a > t.find(s[i-1]) && t[a] == s[i]) n[i]++;
        }
    }

    int m = n[0];

    int p = 0;

    if(indikator == true){
        cout << 0 << endl;
        cout << t;
    }

    else {

        for(int a = 1; a < s.length(); a++){
            if(n[a] < m){
                m = n[a];
                p = a;
            }
        }

        for(int y = 0; y < m; y++){
            t.replace(t.rfind(s[p]), 1, "*");
        }
        cout << m << endl;;

        cout << t;
    }
    return 0;
}