#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

int main()
{
    string rec, cenzura;

    cin >> rec;
    cin >> cenzura;

    int duzina = rec.length();
    int duz = cenzura.length();

    int axz;
    char asd[duzina+1];
    char asb[duz+1];

    bool mini = false;
    int loli = 1000000;
    char asx;
    int m_pos;
    int pon = 0;

    strcpy(asd, rec.c_str());
    strcpy(asb, cenzura.c_str());

    for(int i = 0; i<duzina; i++)
    {
        for(int s = 0; s<duz; s++)
        {
            if(asd[i] == asb[s])
            {
                axz = count(rec.begin(), rec.end(), asd[i]);
                if(axz < loli)
                {
                    loli = axz;
                    m_pos = i;
                    pon = 1;
                    mini = true;
                }
            }
        }
    }
    if(mini)
    {
        cout << loli << endl;

        for(int i = 0; i<duzina; i++)
        {
            if(pon == 1)
            {
                if(asd[i] == asd[m_pos])
                {
                    cout << "*";
                }
                else
                {
                    cout << asd[i];
                }
            }
            else
            {
            cout << asd[i];
            }
        }
    }
    else
    {
        cout << 0 << endl;
        for(int i=0; i<duzina; i++)
        {
            cout << asd[i];
        }
    }
    cout << endl;
    return 0;
}