using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] a = new int[28];
            string s = Console.ReadLine();
            string t = Console.ReadLine();
            for (int i = 0; i < s.Length; i++)
            {
                a[s[i] - 97]++;
            }
            char m = t[0];
            int min = a[t[0] - 97];
            for (int i = 1; i < t.Length; i++)
            {
                if (a[t[i] - 97] < min)
                {
                    min = a[t[i] - 97];
                    m = t[i];
                }
            }
            Console.WriteLine(min);
            foreach (char c in s)
            {
                if (c == m)
                {
                    Console.Write("*");
                }
                else
                {
                    Console.Write(c);
                }
            }
            Console.WriteLine();
        }
    }
}