using System;
using System.Linq;

namespace Takmicenje4
{
    class Program
    {

        static char P;
        public static bool IsSubsequence3(string s, string t)
        {
            var sIndex = 0;
            for (var tIndex = 0; tIndex < t.Length; tIndex++)
            {
                if (s[sIndex] == t[tIndex])
                    sIndex++;

                if (sIndex == s.Length)
                    return true;
            }

            return false;
        }
        static int FindMin(string s, string ds)
        {
            int min = 1000000;
            int count = 0;

            for (int i = 0; i < ds.Length; i++)
            {
                count = s.Count(f => f == ds[i]);
                if (count < min)
                {
                    min = count;
                    P = ds[i];
                }
            }
            return min;
        }

        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string n = Console.ReadLine();
            int br = 0;

            while (IsSubsequence3(n, s))
            {
                int min = FindMin(s, n);
                char[] c = s.ToCharArray();
                c[s.IndexOf(P)] = '*';
                s = new string(c);
                br++;
            }

            Console.WriteLine(br);
            Console.WriteLine(s);
        }
    }
}