// CC #2
#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    string c,cc;
    cin >> c >> cc;
    int kolikogaima[cc.size()];
    char kojeto;
    for(int i = 0; i < cc.size(); i++)
    {
        kolikogaima[cc[i]] = count(c.begin(), c.end(), cc[i]);
    }
    int lowest = 10000, t = 0;
    for(int i = 0; i < cc.size(); i++)
    {
        if(kolikogaima[cc[i]] < lowest) 
        {
            lowest = kolikogaima[cc[i]];
            kojeto = cc[i];
        }
    }
    for(int i = 0; i < c.size(); i++)
    {
        if(kojeto == c[i])
        {
            t++;
            c[i]='*';
        }
    }
    cout << t << endl << c;
    return 0;
}