using System;

namespace CENZURA
{
    class Program
    {
        static void Main(string[] args)
        {
            string t = Console.ReadLine();
            string s = Console.ReadLine();
            char[] T = t.ToCharArray(), S = s.ToCharArray();
            int[] br = new int[26];
            char slovo = S[0];
            if (s != bezDodatnihSlova(t) && s.Length >= t.Length)
            {
                Console.WriteLine("0");
                Console.WriteLine(t);
            }
            else
            {
                for (int i = 0; i < 26; i++)
                {
                    br[i] = 0;
                }
                int j = 0;
                for (int i = 0; i < T.Length; i++)
                {
                    if (S[j] == T[i])
                    {
                        br[(int)S[j] - 97]++;
                    }
                    else if (j < S.Length - 1)
                    {
                        if (br[(int)S[j] - 97] > 0)
                        {
                            j++;
                            i--;
                        }
                        else
                        {
                            j++;
                        }
                    }
                }
                int min = int.MaxValue;
                for (int i = 0; i < 26; i++)
                {
                    if (br[i] < min && br[i] > 0)
                    {
                        min = br[i];
                        slovo = (char)(i + 97);
                    }
                }
                for (int i = 0; i < T.Length; i++)
                {
                    if (T[i] == slovo)
                    {
                        T[i] = '*';
                    }
                }
                Console.WriteLine(br[(int)slovo - 97]);
                Console.WriteLine(T);
            }           
        }

        static string bezDodatnihSlova(string X)
        {
            char[] x = X.ToCharArray();
            int br = 0;
            string t = "";
            t += x[0];
            for(int i = 1; i < x.Length; i++)
            {
                if (x[i] == x[i - 1])
                {
                    br++;
                }
                else
                {
                    br = 0;
                }
                if (br == 0)
                {
                    t += x[i];
                }
            }
            return t;
        }
    }
}