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

namespace ConsoleApplication130
{
    class Program
    {
        static void Main(string[] args)
        {
            string s1 = Console.ReadLine();
            string s2 = Console.ReadLine();
            bool ista_slova = true;
            List<char> l1 = new List<char>();
            foreach (char c in s1)
            {
                l1.Add(c);
            }
            List<char> l2 = new List<char>();
            int i = 0;
            foreach (char c in s2)
            {
                l2.Add(c);
                if(l2[i] != l2[0])
                {
                    ista_slova = false;
                }
                i++;
            }
            if (l2.Count == 1)
            {
                int n = l1.Count();
                string s = "";
                int k = 0;
                for(i = 0; i<n; i++)
                {
                    if(l1[i]==l2[0])
                    {
                        l1[i] = '*';
                        k++;
                    }
                    s += l1[i].ToString();
                }
                Console.WriteLine(k);
                Console.WriteLine(s);
            }
            else
            {
                int b = l2.Count();
                if (ista_slova)
                {
                    int n = l1.Count();
                    int k = 0;
                    string s = "";
                    int bz = 0;
                    for (i = 0; i < n; i++)
                    {
                        if (l1[i] == l2[0] && k < b)
                        {
                            k++;
                        }
                        if (l1[i] == l2[0] && k >= b)
                        {
                            l1[i] = '*';
                            bz++;
                        }
                        s += l1[i].ToString();
                    }
                    Console.WriteLine(bz);
                    Console.WriteLine(s);
                }
                else
                {
                    if(l2.Count == 2)
                    {
                        int aa = 0;
                        int bb = 0;
                        int am = 0;
                        int bm = 0;
                        i = 0;
                        while(l1[i] != l2[0])
                        {
                            if (l1[i] == l2[1])
                            {
                                bm--;
                            }
                            i++;
                        }
                        i = l1.Count - 1;
                        while (l1[i] != l2[1])
                        {
                            if(l1[i] == l2[0])
                            {
                                am--;
                            }
                            i--;
                        }
                        for (i = 0; i < l1.Count; i++)
                        {
                            if (l1[i] == l2[0]) 
                            {
                                aa++;
                            }
                            if (l1[i] == l2[1])
                            {
                                bb++;
                            }
                        }
                        if (aa + am < bb + bm)
                        {
                            for (i = -bm; i < l1.Count + am; i++)
                            {
                                if (l1[i] == l2[0])
                                {
                                    l1[i] = '*';
                                }
                            }
                        }
                        else
                        {
                            for (i = -bm; i < l1.Count + bm; i++)
                            {
                                if (l1[i] == l2[1])
                                {
                                    l1[i] = '*';
                                }
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine("0");
                        Console.WriteLine(s1);
                    }
                }
            }
        }
    }
}