using System;
using System.Text;

namespace jej
{
    class Program
    {
        static void Main(string[] args)
        {
            string t = Console.ReadLine();
            string s = Console.ReadLine();
            int n = t.Length, m = s.Length, c = 0, min = int.MaxValue, br = 0, mm = 0;
            int[] niz = new int[m];
            for (int i = 0; i < n && c != m; i++)
            {
                if (t[i] == s[c]) niz[c]++;
                else if (c < m - 1 && t[i] == s[c + 1] && niz[c] > 0)
                {
                    c++;
                    niz[c]++;
                }
            }
            if (c < m - 1) Console.WriteLine(0);
            else
            {
                for (int i = 0; i < m; i++)
                {
                    if (niz[i] < min)
                    {
                        min = niz[i];
                        mm = i;
                    }
                }
                c = 0;
                niz = new int[m];
                StringBuilder sb = new StringBuilder(t);
                for (int i = 0; i < n && c != m; i++)
                {
                    if (sb[i] == s[c]) niz[c]++;
                    else if (c < m - 1 && sb[i] == s[c + 1] && niz[c] > 0)
                    {
                        c++;
                        niz[c]++;
                    }
                    if (sb[i] == s[mm])
                    {
                        sb[i] = '*';
                        br++;
                    }
                }
                Console.WriteLine(br);
                Console.WriteLine(sb.ToString());
            }
        }
    }
}