using System;

namespace konzola
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string t = Console.ReadLine();
            int n = s.Length;
            int m = t.Length;
            m0(s, t, n, m);
        }

static void m0(string s, string t, int n, int m)
{
    int rez = 0;
    string r = "";
    if(t == "a")
    {
        char c = t[0];
        rez = s.Split(c).Length - 1;
        r = s.Replace(c, '*');
    }
    else if(t.Length - t.Replace("a","").Length == 0)
    {
        int p = 0;
        for(int i = 0; i < n; i++)
        {
            r += s[i];
            if(s[i] == 'a')
            {
                p++;
                if(p == m)
                {
                    p = 0;
                    r = r.Remove(r.Length - 1);
                    r += '*';
                    rez++;
                }
            }
        }
    }
    Console.WriteLine(rez);
    Console.WriteLine(r);
}
    }
}