#include <iostream>
using namespace std;

int main()
{
    string t;
    cin >> t;
    int odb;
    string s;
    cin >> s;
    long long n = t.length();
    long long m = s.length();
    long long a[26], b[26];

    for (int i = 0; i < 27; i++)
    {
        a[i] = 0;
        b[i] = 0;
    }

    for (int i = 0; i < n; i++)
    {
        a[int(t[i]) - 97]++;
    }

    for (int i = 0; i < m; i++)
    {
        b[int(s[i]) - 97]++;
    }

    int maxx = 200001;
    for (int i = 0; i < 27; i++)
    {
        if (a[i] < maxx && b[i] != 0 && a[i] != 0)
        {
            maxx = a[i];
            odb = i;
        }
    }
    cout << a[odb] << endl;

    for(int i = 0;i < n;i++){
        if((int(t[i] - 97)) == odb)
            cout << '*';
        else cout << t[i];
    }

    return 0;
}