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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string t = Console.ReadLine();
            string s= Console.ReadLine();
            int br = 0;
            int j = 0;
            int []x=new int[10];
            for (int i = 0; i < s.Length-1; i++)
            {
                string p = s.Substring(i, 1);
                br = 0;            
                    while (t.Substring(j,1)==p)
                    {
                        br++;
                        j++;
                        x[i] = br;
                    }

                    
            }
            int min = x[0];
            int index = 0;
            for (int i = 1; i < s.Length-1; i++)
            {
                if (min>x[i])
                {
                    min = x[i];
                    index = i;
                }
            }
            int z = 0;
            for (int i = 0; i < index; i++)
            {
                z += x[i];
            }
            string rez = t.Substring(0, z);
            for (int i = 0; i < min; i++)
            {
                rez += "*";
            }
            rez += t.Substring(z + min, t.Length - (z + min));
            Console.WriteLine(min);
            Console.WriteLine(rez);
        }
    }
}