s = eval(input())



c = []

f = s[0]

count = 1

for si in list(s):

  if f != si:

    count += 1

    c.append(count)

    f = si

  else:

    c.append(count)



stone_count = len(set(c))

if stone_count == 2:

  print((1))

  exit()



if stone_count == 1:

  print((0))

  exit()

  

print((stone_count - 1))
def main():

  s = eval(input())

  if set(s) == 1:

    print((0))

    exit()

  group_count = 1

  v = s[0]

  for i in range(1, len(s)):

    if v == s[i]:

      continue

    group_count += 1

    v = s[i]

  print((group_count-1))

    

  



def input_list():

  return list(map(int, input().split()))



import math

main()
s = eval(input())
c = []
f = s[0]
count = 1
for si in list(s):
    if f != si:
        count += 1
        c.append(count)
        f = si
    else:
        c.append(count)
stone_count = len(set(c))
if stone_count == 2:
    print((1))
    exit()
if stone_count == 1:
    print((0))
    exit()
print((stone_count - 1))

def main():
    s = eval(input())
    if set(s) == 1:
        print((0))
        exit()
    group_count = 1
    v = s[0]
    for i in range(1, len(s)):
        if v == s[i]:
            continue
        group_count += 1
        v = s[i]
    print((group_count - 1))


def input_list():
    return list(map(int, input().split()))


import math

main()

-s = eval(input()) -c = [] -f = s[0] -count = 1 -for si in list(s): -    if f != si: -        count += 1 -        c.append(count) -        f = si -    else: -        c.append(count) -stone_count = len(set(c)) -if stone_count == 2: -    print((1)) -    exit() -if stone_count == 1: -    print((0)) -    exit() -print((stone_count - 1)) +def main(): +    s = eval(input()) +    if set(s) == 1: +        print((0)) +        exit() +    group_count = 1 +    v = s[0] +    for i in range(1, len(s)): +        if v == s[i]: +            continue +        group_count += 1 +        v = s[i] +    print((group_count - 1)) + + +def input_list(): +    return list(map(int, input().split())) + + +import math + +main()