using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string s1 = Console.ReadLine();
            int[] br =new int[s1.Length];
            int[] br1 = new int[s1.Length];
            int[] br2 = new int[s1.Length];
            int n =0;
            int m = s.Length;
            int x = s1.Length;
            int i = 0;
            while (i < m && n < x)
            {
                    if (s[i] == s1[n])
                    {
                        br[n] = i;
                    n++;
                }
                i++;
            }
            i = 0;
            n = 0;
            while (i < m && n < x)
            {
                    if (s[m-i-1] == s1[x-n-1])
                    {
                        br1[x-n-1] = m-i-1;
                    n++;
                }
                i++;
            }
            for (int j = 0; j < x; j++)
            {
                for (int c = br[j]; c <= br1[j]; c++)
                {
                    if (s[c] == s1[j])
                    {
                            br2[j]++;
                    }
                }
            }
            int min = br2.Min();
            int p = Enumerable.Range(0, br2.Length).Aggregate((d, l) => (br2[d] < br2[l]) ? d : l);
            StringBuilder sb = new StringBuilder(s);
            for ( i = br[p]; i <= br1[p]; i++)
            {
                if(sb[i]==s1[p])
                {
                    sb[i] ='*';
                }
            }
            Console.WriteLine(min);
            Console.WriteLine(sb);
        }
        }
        
    }