#include <bits/stdc++.h>
#define N 200005
using namespace std;
//ps is now offset
int ps[26][N];

int pf[11];

int sf[11];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    string k;
    cin>>s;
    cin>>k;
    int n = s.length();
    int m = k.length();
    //we go from the front
    pf[0] =0;
    
    for(int j =0;j<26;j++){ps[j][0] =0;}
    int cur = 0;
    for(int i =0;i<n;i++){
       
        if(cur<m&&s[i]==k[cur]){
            pf[cur+1]=i;
            cur++;
        }
       
        //we also need to count prefix sums
        for(int j =0;j<26;j++){
            ps[j][i+1]= ps[j][i];
        }
         
        ps[s[i]-'a'][i+1]++;;
    }
    
    cur = m-1;
    for(int i =n-1;i>=0&&cur>=0;i--){
        
        if(s[i]==k[cur]){
            sf[cur] = i;
            cur--;
        }
    }
    sf[m] = sf[m-1];
    //now we pair up the forward and backward
    int minRem =-1;
    int minRemCnt = 500000;

    for(int rem = 0;rem<m;rem++){
        int cc = ps[k[rem]-'a'][sf[rem+1]+1]-ps[k[rem]-'a'][pf[rem]];
        //cout<<"cmp pairs"<<endl;
        //cout<<sf[rem+1]<<' '<<pf[rem]<<endl;
        //cout<<"!!!!"<<endl;
        if(cc<minRemCnt){
            //cout<<rem<<endl;
            //cout<<cc<<endl;
            
            minRemCnt = cc;
            minRem = rem;
            
        }
    }

    /*
    //dump everything
    for(int j =0;j<26;j++){
        for(int i =0;i<=n;i++){
            cout<<ps[j][i]<<' ';
        }
        cout<<endl;
    }
    cout<<"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"<<endl;
    for(int j=0;j<m;j++){
        cout<<pf[j]<<' ';
    }
    cout<<endl;
    for(int j=0;j<m;j++){
        cout<<sf[j]<<' ';
    }
    cout<<endl;
    */
    //we go through and remove the letter
    int rb = sf[minRem+1];
    
    int lb = pf[minRem];
    char c = k[minRem];
    //cout<<lb<<' '<<rb<<' '<<c<<endl;
    cout<<minRemCnt<<endl;
    for(int i =lb;i<=rb;i++){
        if(c==s[i]){s[i]='*';}
    }
    cout<<s<<endl;
    return 0;
}