using System;
using System.Linq;

namespace Zadatak4
{
    class Program
    {
        static void Main(string[] args)
        {
            string T = Console.ReadLine();
            string S = Console.ReadLine();
            char[] slova_S = S.ToCharArray();
            char[] slova_T = T.ToCharArray();
            int[] br_slova = new int[slova_S.Length];
            int temp = 0;
            for (int i = 0; i < slova_T.Length; i++)
            {
                if (slova_S[temp] == slova_T[i])
                {
                    br_slova[temp]++;
                }
                else
                {
                    temp++;
                    i--;
                }
            }
            for (int i = 0; i < br_slova.Length; i++)
            {
                if (br_slova[i] == 0)
                {
                    int _temp = br_slova[i - 1] - 1;
                    if (br_slova[i - 1] > 1)
                    br_slova[i - 1] -= _temp;
                    br_slova[i] = _temp;
                }
            }
            int br_slova_min = br_slova.Min();
            Console.WriteLine(br_slova_min);
            int index_min_S = 0;
            for (int i = 0; i < br_slova.Length; i++)
            {
                if (br_slova[i] == br_slova_min)
                {
                    index_min_S = i;
                    break;
                }
            }
            int index_min_T = 0;
            for (int i = 0; i < index_min_S; i++)
            {
                index_min_T += br_slova[i];
            }
            for (int i = 0; i < slova_T.Length; i++)
            {
                if (i >= index_min_T && index_min_T + br_slova_min > i)
                {
                    Console.Write("*");
                }
                else
                    Console.Write(slova_T[i]);
            }
        }
    }
}