#include <iostream>

using namespace std;

int main()
{
    int a[1000], n=0, br=0, m=0, mini=a[0], suma=0, q=0, i=0;
    string t, s;
    cin >> t >> s;
    int h=0, u=0;
    while(t[h]!='\0'){
        u++;
        h++;
    }
    while(t[n]!='\0'){
        for(n=0; n<u ;n++){
            if(t[n]==s[i] && t[n+1]==s[i]){
                br++;
            }
            else if(t[n]==s[i] && t[n+1]!=s[i]){
                br++;
                a[m]=br;
                suma=suma+a[m];
                if(a[m]<mini && a[m]!=0){
                    mini=a[m];
                    q=suma-mini;
                }
                br=0;
                m++;
                i++;

            }
            else if(t[n]!=s[i]){
                suma++;
            }
        }
    }
    cout << mini << endl;
    for(int i=q; i<q+mini; i++){
        t[i]='*';
    }
    cout << t;
    return 0;
}