using System;
using System.Collections.Generic;
using System.Linq;

namespace Cenzura
{
    class Program
    {
        static string zameni(string T, int i, int length) 
        {
            string dodatak = "";
            for (int p = 0; p < length; p++) dodatak += "*";
            return T.Substring(0, i) + dodatak + T.Substring(i + length);
        }

        static void Main(string[] args)
        {
            string T = Console.ReadLine();
            string S = Console.ReadLine();
            if (S.Length == 1)
            {
                Console.WriteLine(T.Count(x => x == S[0]));
                Console.WriteLine(T.Replace(S[0], '*'));
            }
            else 
            {
                int minIndeks = -1;
                int minBrojac = -1;

                int indeks = 0;
                int brojacT = 0;
                int brojacS = 0;
                int j = 0;
                int i = 0;

                int brIzmena = 0;
                while (i < T.Length)
                {
                    if (T[i] == S[j])
                    {
                        brojacT = 0;
                        brojacS = 0;
                        indeks = i;
                        char trenutna = T[i];
                        while (i < T.Length && T[i] == trenutna)
                        {
                            i++;
                            brojacT++;
                        }
                        trenutna = S[j];
                        while (j < S.Length && S[j] == trenutna)
                        {
                            j++;
                            brojacS++;
                        }
                        if (minBrojac == -1 || (brojacS <= brojacT && brojacT - brojacS + 1 < minBrojac))
                        {
                            minBrojac = brojacT - brojacS + 1;
                            minIndeks = indeks;
                        }
                        if (j == S.Length)
                        {
                            T = zameni(T, minIndeks, minBrojac);
                            brIzmena += minBrojac;
                            minBrojac = -1;
                            minIndeks = -1;
                            j = 0;
                        }
                    }
                    else i++;
                }
                Console.WriteLine(brIzmena);
                Console.WriteLine(T);
            }
        }
    }
}