#include <iostream>
#include <string>
#include <cmath>
using namespace std;

string replace(string s, char c1, char c2)
{
    int l = s.length();
 
    for (int i = 0; i < l; i++) {
 
        if (s[i] == c1)
            s[i] = c2;
    }
    return s;
}

int count(string s, char c)
{
    int res = 0;
 
    for (int i=0;i<s.length();i++){
        if (s[i] == c)
            res++;
    }
 
    return res;
}
int main() {
    string T; cin>>T;
    string S; cin>>S;
    int z;
    int m =0;
    int t= T.length();
    char x[30];
    int brojTihSlova[30];
    int brojSubteksta[30];
    for(int i = 97; i<= 122; i++){
        x[i] = i;
        brojTihSlova[i] = count(T, x[i]);
        brojSubteksta[i] = count(S,x[i]);
        if((brojTihSlova[i] >0 && brojSubteksta[i] >0 ) && (brojSubteksta[i]== brojTihSlova[i])){
            z=i;
            m++;
        }

        
    }        
    char c1= z;
    char c2= int(42);
    cout <<m<<endl<< replace(T, c1, c2);
}