using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int j, x, y;
            int[] a = new int[28];
            string s = Console.ReadLine();
            string t = Console.ReadLine();
            char[] c = s.ToCharArray();
            for (int i = 0; i < s.Length; i++)
            {
                a[s[i] - 97]++;
            }
            char m = t[0];
            for (int i = 1; i < t.Length; i++)
            {
                if (a[t[i] - 97] < a[m - 97])
                {
                    m = t[i];
                }
            }
            j = x = 0;
            while (t[j] != m)
            {
                if (s[x] == t[j])
                {
                    j++;
                }
                x++;
            }
            j = t.Length - 1;
            y = s.Length - 1;
            while (t[j] != m)
            {
                if (s[y] == t[j])
                {
                    j--;
                }
                y--;
            }
            j = 0;
            for (int i = x; i <= y; i++)
            {
                if (s[i] == m)
                {
                    j++;
                    c[i] = '*';
                }
            }
            Console.WriteLine(j);
            foreach (char i in c)
            {
                Console.Write("{0}", i);
            }
            Console.WriteLine();
        }
    }
}