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

namespace cenzura
{
    internal class Program
    {
        static void Main(string[] args)
        {
            string t = Console.ReadLine();
            string s = Console.ReadLine();
            char[] c = new char[t.Length];
            char[] c1 = new char[t.Length];
            char[] c2 = new char[t.Length];
            int x = 0, p = 0, q = 0, r = 0;
            if (s == "a")
            {
                for (int i = 0; i < t.Length; i++)
                {
                    if (t[i] == 'a')
                    {
                        c[i] = '*';
                        x++;
                    }
                    else c[i] = t[i];
                }
                Console.WriteLine(x);
                for (int i = 0; i < t.Length; i++)
                {
                    Console.Write(c[i]);
                }
                Console.WriteLine();
            }
            else if (s == "ab")
            {
                for (int i = 0; i < t.Length; i++)
                {
                    if (t[i] == 'a')
                    {
                        c1[i] = t[i];
                        for (int j = i + 1; j < t.Length; j++)
                        {
                            if (t[j] == 'b')
                            {
                                c1[j] = '*';
                                p++;
                            }
                        }
                    }
                    else c1[i] = t[i];
                }
                for (int i = t.Length - 1; i >= 0; i--)
                {
                    if (t[i] == 'b')
                    {
                        c2[i] = t[i];
                        for (int j = i - 1; j >= 0; j--)
                        {
                            if (t[j] == 'a')
                            {
                                c2[j] = '*';
                                q++;
                            }
                        }
                    }
                    else c2[i] = t[i];
                }
                if (p >= q)
                {
                    Console.WriteLine(p);
                    for (int i = 0; i < t.Length; i++)
                    {
                        Console.Write(c1[i]);
                    }
                    Console.WriteLine();
                }
                else
                {
                    Console.WriteLine(q);
                    for (int i = 0; i < t.Length; i++)
                    {
                        Console.Write(c2[i]);
                    }
                    Console.WriteLine();
                }
            }
            else if (s[0] == 'a' && s[1] == 'a') 
            {
                for (int i = 0; i < t.Length; i++)
                {
                    c[i] = t[i];
                    if (t[i] == 'a')
                    {
                        r++;
                    }
                }
                x = r;
                if (r >= s.Length)
                {
                    for (int i = 0; i < t.Length; i++)
                    {
                        if (t[i] == 'a')
                        {
                            c[i] = '*';
                            r--;
                        }
                        if (r < s.Length) break;
                    }
                }
                Console.WriteLine(x - s.Length + 1);
                for (int i = 0; i < t.Length; i++)
                {
                    Console.Write(c[i]);
                }
                Console.WriteLine();
            }
            else Console.WriteLine(0);
        }
    }
}