using System;

namespace CENZURA
{
    class Program
    {
        static void Main(string[] args)
        {
            string t = Console.ReadLine();
            string s = Console.ReadLine();
            int m = s.Length;
            int n = t.Length;
            string a=t.Remove(0, t.IndexOf(s[0]));
            string b="";
            int min = n;
            string z="";
            int k = 0;
            bool con = false;
            for (int i = 0; i < m; i++)
            {
                if (t.Contains(s[i]))
                {
                    con = true;
                }
            }
            if (con)
            {
                if (t[n - 1] != s[m - 1])
                {
                    a = a.Remove(a.LastIndexOf(s[m - 1]) + 1);
                }
                Console.WriteLine(a);
                for (int i = m - 1; i >= 0; i--)
                {
                    if (i != 0)
                    {
                        Console.WriteLine(s[i]);
                        string y = a.Substring(a.LastIndexOf(s[i - 1]) + 1);
                        Console.WriteLine("   y = " + y);
                        int x = y.Length - y.Replace(s[i].ToString(), "").Length;
                        if (x < min)
                        {
                            min = x;
                            b = y;
                            z = s[i].ToString();
                            k = a.IndexOf(y);
                        }
                        a = a.Replace(y, "");
                        Console.WriteLine("   a = " + a + "\n   x = " + x);
                    }
                    else
                    {
                        Console.WriteLine(s[i]);
                        string y = a;
                        Console.WriteLine("   y = " + y);
                        int x = y.Length - y.Replace(s[i].ToString(), "").Length;
                        if (x < min)
                        {
                            min = x;
                            b = y;
                            z = s[i].ToString();
                        }
                        a = a.Replace(y, "");
                        Console.WriteLine("   a = " + a);
                    }
                }
                string s1 = t.Substring(k + t.IndexOf(s[0]), k + t.IndexOf(s[0]) + b.Length);
                Console.WriteLine("{0}\n{1}", min, t.Replace(s1, s1.Replace(z, "*")));
            }
            else
            {
                Console.WriteLine(0 + "\n" + t);
            }
        }
    }
}