#include <bits/stdc++.h>
using namespace std;
int N;
int solution[11][11];
void ADDSol(int index )
{ 
    solution[index][index]++;
    for(int z = 0; z < index; z++)
    {  
        solution[z][index] += solution[z][index - 1];
        solution[z][index - 1] = 0;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);



    int K = 0;
    string  S; cin >> S;
    string BadWord; cin >> BadWord; 
     N = BadWord.size(); 



    for(int i =0; i<S.size();i++)
    { 
        for(int j = 0; j < K; j++)
        { 
            if(BadWord[j] == S[i])
            { 
                ADDSol(j);
            }
        }

        if(S[i] == BadWord[K])
        { 
            ADDSol(K);
            K++;
        }
    }

    int minI = 0;
    for(int i = 1; i < N; i++)
    { 
        if(solution[i][N-1] < solution[minI][N-1])
            minI = i;
    }
    int i = 0 , l = 0;
    while(l < minI)
    { 
        if(BadWord[l] == S[i])
            l++;
        i++;
    }

int R = solution[minI][N -1 ];
while(R > 0)
{ 
    if(S[i] == BadWord[minI])
    { 
        S[i] = '*';
        R--;
    }
    i++;
}
cout << solution[minI] [N-1] << "\n";
cout << S;
    return 0;
}