#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <climits>
#include <vector>

using namespace std;

int main(){
    
    string t, s;
    
    cin >> t >> s;

    vector <int> a(s.size(),0);
    int i=0, min = INT_MAX, index;
    while (s[i]!='\0'){
        for(int j=0;j<t.size();j++)
            if(s[i]==t[j]) 
                a[i]++;
        if(a[i]<min){
            min = a[i];
            index = i;
        }
        i++;
    }
    int k=0;
    for(int j=0;j<index;j++) k+=a[j]; 
    for(int j=k;j<k+a[index];j++) t[j]='*';
    cout <<a[index]<<endl<< t;

    return 0;
}