using System;

public class Class1
{
    static void Main(string[] args)
    {
        var Class1 = new Class1();
    }

	public Class1()
	{
        string S = Console.ReadLine();
        int ChangeCount = 0;
        Color Recent = judge(S[1]);
        for (int i = 1; i < S.Length; i++)
        {
            if (Recent != judge(S[i])) ChangeCount++;
            Recent = judge(S[i]);
        }

        Console.WriteLine(ChangeCount);

	}

    public Color judge(char c)
    {
        if (c == 'B') return Color.black;
        else return Color.white;
    }

    
}

public enum Color
{
    black,white
}
