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

namespace Piramida
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            char[] c = s.ToCharArray();

            string s1 = Console.ReadLine();
            char[] c1 = s1.ToCharArray();

            int a = 0, inx = 0, inxt = 0, b = int.MaxValue;
            for (int i = 0; i < c1.Length; i++)
            {
                for (int j = 0; j < c.Length; j++)
                {
                    if (c1[i] == c[j])
                    {
                        a++;
                        inxt = i;
                    }
                }
                if(a<b)
                {
                    inx = inxt;
                    b = a;
                    
                }
                inxt = 0;
                a = 0;
            }

            int br = 0;
            for(int i = 0; i<c.Length; i++)
            {
                if(c[i] == c1[inx])
                {
                    c[i] = '*';
                    br++;
                }
            }

            Console.WriteLine(br);
            for(int i = 0; i<c.Length; i++)
            {
                Console.Write(c[i]);
            }
        }
    }
}