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

namespace ConsoleApplication8
{
    class Program
    {
        static void Main(string[] args)
        {
            string corba = Console.ReadLine().ToString();
            string rec = Console.ReadLine().ToString();
            Dictionary<char,int> brojevi=new Dictionary<char,int>();
            int broj=0; char slovo=';';
            foreach (char x in rec)
            {
                int brojac = corba.Count(o => o == x);
                brojevi.Add(x,brojac);
                broj = brojevi.Values.Min();
                slovo = brojevi.FirstOrDefault(x1 => x1.Value == broj).Key;
            }
            Console.WriteLine(broj);
            Console.WriteLine(corba.Replace(slovo, '*'));
            Console.ReadKey();
        }
    }
}