using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void ucitavanje(string T, List<char> a)
    {
        for (int i = 0; i < T.Length; i++)
        {
            a.Add(T[i]);
        }
    }

    static void ispis(string S, string T, List<char> a)
    {
        char promena = provera(S, a);

        for (int i = 0; i < T.Length; i++)
        {
            if (a[i] != promena)
            {
                Console.Write(a[i]);
            }

            else
            {
                Console.Write("*");
            }
        }
    }

    static char provera(string S, List<char> a)
    {
        char promena = ' ';
        Int64 minimum = Int64.MaxValue;

        for (int i = 0; i < S.Length; i++)
        {
            if (a.Contains(S[i]))
            {
                Int64 brojac = a.Count(Item => Item == S[i]);

                if (brojac < minimum)
                {
                    minimum = brojac;
                    promena = S[i];
                }
            }
        }

        Console.WriteLine(minimum);

        return promena;
    }

    static void Main()
    {
        // ucitavamo ulazne podatke

        string T = Console.ReadLine();
        string S = Console.ReadLine();

        List<char> a = new List<char>();

        ucitavanje(T, a);

        // ispis

        ispis(S, T, a);
    }
}