pattern = raw_input()

first = pattern[0]
search = 'W' if first == 'B' else 'B'

moves = 0
spot = pattern.find(search)
while spot != -1:
    search = 'W' if search == 'B' else 'B'
    moves += 1
    pattern = pattern[spot:]
    spot = pattern.find(search)

print moves
