#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>



using namespace std;

int main()
{
    cin.tie(0);
    std::ios_base::sync_with_stdio(false);

    string s1, s2;
    cin >> s1;
    cin >> s2;
    map<char, long int> mymap, secondmap;
    int i = 0;
    int j = 0;
    while(j < s2.size())
    {
        secondmap[s2[j]]++;
        j++;
    }

    while(i < s1.size())
    {
        auto it = secondmap.find(s1[i]);
        if(it != secondmap.end())
             mymap[s1[i]]++;


        i++;
    }
    long int minn = 200001;
    char myword;
    for(auto it : mymap)
    {
        if(it.second < minn)
        {
            myword = it.first;
            minn= it.second;
        }
    }
    cout << mymap[myword] << "\n";
    for(int i = 0; i < s1.size(); i++)
    {
        if(s1[i] == myword)
            cout << "*";
        else
            cout << s1[i];
    }
    cout << "\n";

    return 0;
}