using System;

namespace Rec
{
    class Program
    {
        static void Main(string[] args)
        {
            string T = Convert.ToString(Console.ReadLine());
            string S = Convert.ToString(Console.ReadLine());
            int br = 0;
            int min = int.MaxValue;
            for (int i = T.Length-1; i > 0; i--)
            {
                if (T[i]==T[i-1])
                {
                    br++;
                    continue;
                }
                if (br<min)
                {
                    min = br;
                }
            }
            Console.WriteLine(min);
        }
    }
}