using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace cenzuraMutava
{
    internal class Program
    {
        static void Main(string[] args)
        {
            string text = Console.ReadLine();
            char[] textNiz = new char[text.Length];
            for (int i = 0; i < text.Length; i++)
            {
                textNiz[i] = text[i];
            }
            int suma = 0;
            string zabranjena = Console.ReadLine();
            if (zabranjena.Length == 1)
            {
                for (int i = 0; i < text.Length; i++)
                {
                    if (text[i] == zabranjena[0])
                    {
                        textNiz[i] = '*';
                        suma++;
                    }
                }
            }
            else if (zabranjena.Length > 1)
            {
                Console.Write(zabranjena);
            }
            bool[] tacnost = new bool[text.Length];
            if (zabranjena == "ab")
            {
                /*int levo = 0;
                int desno = 0;
                for (int i = 0; i < text.Length - 1; i++)
                {
                    if (text.Substring(i, i + 1) == "ab")
                    {
                        for(int j = i;(j>=0);)
                        {
                            if (text[j] == 'a')
                            {
                                j--;
                                levo++;
                            }
                            else
                            {break;}
                        }
                        for (int k = i; (k <= text.Length);)
                        {
                            if (text[k] == 'b')
                            {
                                k++;
                                desno++;
                            }
                            else
                            {break;}
                        }
                        if(desno>levo)
                        {
                            for(int j = i; j>;)
                        }
                    }
                }*/
            }
            Console.WriteLine(suma);
            for (int i = 0; i < textNiz.Length; i++)
            {
                Console.Write(textNiz[i]);
            }
        }
    }
}