using System;
using System.Linq;
using System.Text;

namespace ConsoleApp53
{
    class Program
    {
        static void Main(string[] args)
        {
            string p = Console.ReadLine();
            string s = Console.ReadLine();
            int[] a1 = new int[s.Length];
            int[] a2 = new int[s.Length];
            int[] a3 = new int[s.Length]; int br = 0;
            for (int i = 0; i < p.Length; i++)
            {
                if (br<s.Length && p[i] == s[br])
                {
                    a1[br] = i;
                    br++;
                }
                if (br > 0)
                {
                    for (int j = 0; j < s.Length; j++)
                    {
                        if (p[i] == s[j])
                        {
                            a2[j] = i;
                            a3[j]++;
                        }
                    }
                }
            }
            int q = a3.Min();
            int k = Enumerable.Range(0, a3.Length).Aggregate((a, b) => (a3[a] < a3[b]) ? a : b);
            StringBuilder sb = new StringBuilder(p);
            sb.Replace(s[k], '*', a1[k], a2[k]-a1[k]+1);
            Console.WriteLine(q);
            Console.WriteLine(sb);

        }
    }
}