# -*- coding: utf-8 -*-



from itertools import groupby



s = eval(input())



ans = len(list(groupby(s))) - 1

print(ans)

# -*- coding: utf-8 -*-



s = eval(input())



ans = s.count("WB") + s.count("BW")

print(ans)

# -*- coding: utf-8 -*-
from itertools import groupby

s = eval(input())
ans = len(list(groupby(s))) - 1
print(ans)

# -*- coding: utf-8 -*-
s = eval(input())
ans = s.count("WB") + s.count("BW")
print(ans)

-from itertools import groupby - -ans = len(list(groupby(s))) - 1 +ans = s.count("WB") + s.count("BW")