Two foxes Jiro and Saburo are playing a game called 1D Reversi. This game is played on a board, using black and white stones. On the board, stones are placed in a row, and each player places a new stone to either end of the row. Similarly to the original game of Reversi, when a white stone is placed, all black stones between the new white stone and another white stone, turn into white stones, and vice versa.
In the middle of a game, something came up and Saburo has to leave the game. The state of the board at this point is described by a string S. There are |S| (the length of S) stones on the board, and each character in S represents the color of the i-th (1 ≦ i ≦ |S|) stone from the left. If the i-th character in S is B, it means that the color of the corresponding stone on the board is black. Similarly, if the i-th character in S is W, it means that the color of the corresponding stone is white.
Jiro wants all stones on the board to be of the same color. For this purpose, he will place new stones on the board according to the rules. Find the minimum number of new stones that he needs to place.

-----Constraints-----
 - 1 ≦ |S| ≦ 10^5
 - Each character in S is B or W.

-----Input-----
The input is given from Standard Input in the following format:
S

-----Output-----
Print the minimum number of new stones that Jiro needs to place for his purpose.

-----Sample Input-----
BBBWW

-----Sample Output-----
1

By placing a new black stone to the right end of the row of stones, all white stones will become black. Also, by placing a new white stone to the left end of the row of stones, all black stones will become white.
In either way, Jiro's purpose can be achieved by placing one stone.

Difficulty: introductory

Starter code:

Solutions:
s= input()
color = "chokudai"
d = []

for c in s:
    if c != color:
        d.append(c)
        color = c
print(len(d)-1)

s = input()
cnt = 1
cw = s[0]
for i in range(len(s)):
  if s[i] != cw: 
    cnt += 1
    cw = s[i]
print(cnt - 1)

S = str(input())
Sum = 0  
for i in range(len(S) - 1):
    if S[i] != S[i + 1]:
        Sum += 1

print(Sum)

s = input()
print((sum((s[i] != s[i+1] for i in range(len(s)-1)))))


s=input()
ans=0
for i in range(len(s)-1):
    if s[i]!=s[i+1]:
        ans+=1
print(ans)


s = input()
tmp = s[0]
cnt = 0
for c in s:
    if tmp != c:
        tmp = c
        cnt += 1
print(cnt)

S = list(input())
count = 0
t = ''
for i in S:
    if t == i:
        continue
    else:
        t = i
        count += 1
print(count - 1)

s=input()

color = s[0]
result = 0
for i in range(len(s)):
  if color != s[i]:
    result += 1
    color = s[i]
print(result)

S = input()
count = 0
for i in range(len(S)-1):
    if S[i] != S[i+1]:
        count += 1
print(count)

s=list(input())
tmp=0
for i in range(1,len(s)):
    if s[i-1] != s[i]:
        tmp+=1
print(tmp)

S = input()
#0回判定
x = len(S)
if S.count("B") == x or S.count("W") == x:
    print(0)
    return



cntw=0
for s in S.split("W"):
    if s:
        cntw += 1
cntb=0
for s in S.split("B"):
    if s:
        cntb += 1
print(abs(cntb - cntw) + min(cntb, cntw) * 2 - 1)

def main():
    S = input()
    ans = 0
    for i, s in enumerate(S):
        if i == 0:
            t = s
            continue
        if t == s:
            continue
        else:
            ans += 1
            t = s
    print(ans)
        
def __starting_point():
    main()

__starting_point()

s = input()
ans = 0
for i in range(len(s)-1):
    if s[i] != s[i+1]:
        ans += 1
print(ans)

s = input()
cnt = 0
for i in range(1, len(s)):
    if s[i] != s[i-1]:
        cnt += 1
print(cnt)

def main():
    s = str(input())
    b_count = s.count('B')
    w_count = len(s) - b_count

    if b_count == len(s) or w_count == len(s):
        count = 0
    else:
        count = 0
        index = 0
        alp = s[index]

        while True:
            if b_count == 0 or w_count == 0:
                break
            else:
                if s[index] == 'B':
                    b_count -= 1
                else:
                    w_count -= 1

                if s[index] == alp:
                    index += 1
                else:
                    count += 1
                    alp = s[index]
                    index += 1

        if not (b_count == 0 and w_count == 0):
            count += 1

    print(count)


def __starting_point():
    main()
__starting_point()

S=input()
print(S.count("BW")+S.count("WB"))

s=input()
c=0
t=s[0]
for k in s[1:]:
    if t!=k:
        t=k
        c+=1
print(c)


S = input()
cnt = 0
now = S[0]

for i in S:
    if i != now:
        now = i
        cnt += 1
print(cnt)

S = input()
prev = S[0]
cnt = 0
for s in S:
    if prev != s:
        cnt += 1
    prev = s
print(cnt)

S = input()
ans = 0

for i in range(len(S)-1):
  if S[i] != S[i+1]:
    ans += 1

print(ans)

s = input()
cnt = 0
for i in range(1,len(s)):
  if s[i] != s[i-1]: 
    cnt += 1
print(cnt)

s = input()
c = s[0]
ans = 0
for i in range(1, len(s)):
    if c != s[i]:
        ans += 1
    c = s[i]
print(ans)

#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from math import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
import heapq
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
# mod = 9982443453
# mod = 998244353
INF = float('inf')
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
    return int(readline())
S = input()
ans = 0
for i in range(len(S)-1):
    if S[i+1] != S[i]:
        ans += 1
print(ans)


S = input()
l = len(S)
ans = sum(a != b for a,b in zip(S[:l-1],S[1:]))
print(ans)

from collections import Counter
S = input()

c = Counter(S)
if c['W'] == 0 or c['B'] == 0:
    print((0))
    return

now = ''
count = 0
for i in range(len(S)):
    if i == 0:
        now = S[i]
        continue
    if now == S[i]:
        continue
    else:
        count += 1
        now = S[i]
        continue

print(count)


s = list(input())
ans = 0
for i in range(1, len(s)):
    if s[i] != s[i-1]:
        ans += 1
print(ans)

s = input()
count = 0
for i in range(len(s)-1):
    if s[i] != s[i+1]:
        count += 1
print(count)

S = input()

ls = ["WB", "BW"]

cnt = 0
if S[0] == "W":
  i = 0
else:
  i = 1

for j in range(len(S)-1):
  if i == 0 and S[j:j+2] == "WB":
    cnt += 1
    i = 1
  if i == 1 and S[j:j+2] == "BW":
    cnt += 1
    i = 0
    
print(cnt)

s = input()
ans = 0
for i in range(1, len(s)):
    if s[i] != s[i - 1]:
        ans += 1
print(ans)

prev = '0'
S = ''
for c in input():
    if c != prev:
        S += c
    prev = c
print(len(S) - 1)

s = list(input())
n = len(s)
b = False
if s[0] == "B":
    b = True

ans = 0
for i in range(1, n):
    if b and s[i] == "W":
        b = False
        ans += 1
    elif not b and s[i] == "B":
        b = True
        ans += 1
print(ans)

s=input()
count=0
for i in range(1,len(s)):
    if s[i-1]!=s[i]:
        count+=1
print(count)


# -*- coding: utf-8 -*-
"""
Created on Wed Sep 30 02:12:31 2020

@author: liang
"""

S = input()
ans = 0
for i in range(len(S) - 1):
    if S[i] != S[i+1]:
        ans += 1

print(ans)

import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return list(map(int, input().split()))
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    s = s_input()
    ans = 0
    trial = s[0]
    for i in s[1:]:
        if trial != i:
            ans += 1
            trial = i
    print(ans)


def __starting_point():
    main()

__starting_point()

S = input()
c = 0

bs = '_'
for s in S:
  if s != bs:
    c += 1
    bs = s

print(c - 1)

class Combination:
    def __init__(self, n, mod):
        self.n = n
        self.mod = mod
        self.fac = [1 for i in range(self.n + 1)]
        self.finv = [1 for i in range(self.n + 1)]
        for i in range(2, self.n+1):
            self.fac[i] = (self.fac[i - 1] * i) % self.mod
            self.finv[i] = (self.finv[i - 1] * pow(i, -1, self.mod)) % self.mod

    def comb(self, n, m):
        return self.fac[n] * (self.finv[n - m] * self.finv[m] % self.mod) % self.mod
        
def iparse():
    return list(map(int, input().split()))

def RLE(s):
    res = []
    prev = ""
    cnt = 0
    for e in s:
        if prev == "":
            prev = e
            cnt += 1
        elif prev == e:
            cnt += 1
        else:
            res.append((cnt,prev))
            prev = e
            cnt = 1
    res.append((cnt,prev))
    return res


def __starting_point():
    s = input()
    rle = RLE(s)
    # print(rle)
    print(len(rle)-1)
__starting_point()

s = input()
counter = 0

for i in range(1, len(s)):
    if s[i] != s[i - 1]:
        counter += 1

print(counter)


from itertools import groupby
s = input()
count = 0
for k, g in groupby(s):
    count += 1
print(count - 1)

s=input()
ans=[]
pre=""
for i in s:
    if pre!=i:
        ans.append(i)
        pre=i

print(len(ans)-1)

S = input()

s = S.replace('WB', 'W B').replace('BW', 'B W')
s = list(s.split())
print(len(s) -1)

#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-10-09 16:08:34 +0900
# LastModified: 2020-10-09 16:19:59 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd
from itertools import groupby


def main():
    S = input()
    sgroup = groupby(S)
    for cnt, (key, group) in enumerate(sgroup):
        pass
    print(cnt)






def __starting_point():
    main()

__starting_point()

import sys

input = sys.stdin.readline
S = input()
S = S.replace('\n' , '')
tmp = ""
division_count = 0
for s in S:
    if tmp == "":
        tmp = s
        continue
    if tmp == s:
        continue
    else:
        tmp = s
        division_count += 1
print(division_count)

prev = '0'
ans = -1
for c in input():
    if c != prev:
        ans += 1
    prev = c
print(ans)

s = input()
cnt = 0
for i in range(len(s)-1):
    if s[i+1] != s[i]:
        cnt += 1
print(cnt)

from itertools import groupby
print(len(list(groupby(input())))-1)

s = input()
print(s.count("BW")+s.count("WB"))

from itertools import groupby

s = input()

cnt = 0

for k, g in groupby(s):
    cnt += 1

print((cnt - 1))


s = input()
if len(s) == 1:
    print(0)
else:
    cnt = 0
    for i in range(len(s)-1):
        if s[i] != s[i+1]:
            cnt += 1

    print(cnt)

a=input()+"p"
b=0
i=1
c=a[0]
while a[i]!="p":
  if a[i]!=c:
    c=a[i]
    b+=1
  i+=1
print(b)

S=input()
N=len(S)

count=0
for i in range(N-1):
    if S[i]!=S[i+1]:
        count+=1

print(count)


S = input()
ans = 0
for i in range(1,len(S)):
  if S[i] != S[i-1]:
    ans += 1
print(ans)

def main():
    *S, = input()
    c = S.pop()
    ans = 0
    while S:
        if (nc := S.pop()) == c:
            continue
        c = nc
        ans += 1
    print(ans)


def __starting_point():
    main()

__starting_point()

#!/usr/bin/env python

s = input()
ans = 0 
for i in range(len(s)-1):
    if s[i+1] != s[i]:
        ans += 1
print(ans)


s = list(input())

count = 0
for i in range(len(s) - 1):
    if s[i] != s[i + 1]:
        count += 1

print(count)

#!/usr/bin/env python3
import sys


def solve(S: str):
    S = [s1 for s0, s1 in zip(S, S[1:]+".") if s0 != s1]
    return len(S) - 1


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    print((solve(S)))

def test():
    import doctest
    doctest.testmod()

def __starting_point():
    #test()
    main()

__starting_point()

s=list(input())
cnt=0
bf=s[0]
for i in s[1:]:
  if i!=bf:
    cnt+=1
  bf=i
print(cnt)

s=input()
n=len(s)
ans=0
for i in range(n-1):
  if s[i]==s[i+1]:
    continue
  else:
    ans+=1
print(ans)

s = input()
ans = 0
p = s[0]
for si in s:
    ans += p != si
    p = si
print(ans)

S=input()
ans=0
N=len(S)
now=S[0]
for i in range(1,N):
    if now!=S[i]:
        now=S[i]
        ans+=1
print(ans)

#81 C - 一次元リバーシ
S = input()
S = S + '1'# 番兵

# 連続する文字をカウント
cnt = []
conti = 1
for i in range(1,len(S)):
    if S[i-1] == S[i]:
        conti += 1
    else:
        cnt.append(conti)
        conti = 1
print(len(cnt)-1)

s = input()
a = 0
for i in range(len(s) - 1):
    if s[i] != s[i + 1]:
        a += 1
print(a)


#
# abc047 c
#

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """BBBWW"""
        output = """1"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """WWWWWW"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """WBWBWBWBWB"""
        output = """9"""
        self.assertIO(input, output)


def resolve():
    S = list(input())

    i = 1
    while i < len(S):
        if S[i] == S[i-1]:
            del S[i]
        else:
            i += 1

    print((len(S)-1))


def __starting_point():
    # unittest.main()
    resolve()

__starting_point()

s = input()
temp = s[0]
ans = 0
for l in s:
  if temp!=l:
    ans += 1
  temp = l
print(ans)

def solve():
    s = input()
    ans = 0
    for i in range(len(s)-1):
        if s[i] != s[i + 1]:
            ans += 1
    print(ans)

def __starting_point():
    solve()
__starting_point()

from itertools import groupby

S = input()

print((len(list(groupby(S)))-1))


s = input()
ans = 0

for i in range(len(s)-1):
  if s[i] != s[i+1]:
    ans += 1

print(ans)

from itertools import groupby


# RUN LENGTH ENCODING str -> tuple
def runLengthEncode(S: str):
    grouped = groupby(S)
    res = []
    for k, v in grouped:
        res.append((k, str(len(list(v)))))
    return res


# RUN LENGTH DECODING tuple -> str
def runLengthDecode(L: "list[tuple]"):
    res = ""
    for c, n in L:
        res += c * int(n)
    return res


# RUN LENGTH ENCODING str -> list
def rle_list(S: str):
    grouped = groupby(S)
    res = ""
    for k, v in grouped:
        res += k
    return res


def main():
    ss = input()
    rle = rle_list(ss)
    ans = len(list(rle)) - 1
    print(ans)


def __starting_point():
    main()

__starting_point()

s = list(input())
ans = 0
t = s[0]
for i in range(1,len(s)):
    if s[i] != t:
        t = s[i]
        ans += 1
print(ans)

s = input()
count = 0
for i in range(len(s)-1):
    if s[i] != s[i+1]:
        count += 1
print(count)

s = input()
count = 0

for i in range(len(s)-1):
  if s[i] != s[i+1]:
    count += 1
print(count)

def main():
    ss = input()
    put_stone = ''
    count = 0
    for stone in ss:
        if put_stone != '' and put_stone == stone:
            count += 1
        if stone == 'B':
            put_stone = 'W'
        else:
            put_stone = 'B'
    print(count)

def __starting_point():
    main()
__starting_point()

S = input()
now = S[0]
cnt = 0
for s in S:
    if now == s:
        continue
    cnt += 1
    now = s
print(cnt)

S = input()
print(S.count('BW')+S.count('WB'))

S=input()
ans=0
for i in range(len(S)-1):
    if S[i]!=S[i+1]:
        ans+=1
print(ans)


S = input()
List = list(S)
trial = 0
for i in range(1,len(List)):
  if List[i] != List[i-1]:
    trial += 1
print(trial)

#!/usr/bin/env python3
import sys


def solve(S: str):
    from itertools import groupby
    return len(list(groupby(S))) - 1


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    print((solve(S)))

def test():
    import doctest
    doctest.testmod()

def __starting_point():
    #test()
    main()

__starting_point()

s = input()
ans = 0
x = s[0]

for i in range(len(s)):
    if s[i] != x:
        ans += 1
        x = s[i]

print(ans)

def main():
    s = input()
    print((sum([1 for i in range(len(s) - 1) if s[i] != s[i + 1]])))


def __starting_point():
    main()

__starting_point()

s = input()

n = len(s)

cnt = 0
for i in range(1,n):
  if s[i] != s[i-1]:
    cnt +=1
print (cnt)


S=str(input())
ans=0
for i in range(1,len(S)):
    if S[i-1]!=S[i]:
        ans+=1
print(ans)

s = input()
prev = s[0]
ans = 0
for i in range(1, len(s)):
    if s[i] != prev:
        ans += 1
    prev = s[i]
print(ans)


s = input()
cnt = 0
for i in range(len(s)-1):
    if s[i] != s[i+1]:
        cnt += 1

print(cnt)

s=input()
x=s.count("WB")
y=s.count("BW")
print((x+y))


S = list(input())
k = S.pop(0)
ii = 0
for i in S:
    if k == i:
        pass
    else:
        ii += 1
        k = i
print(ii)

s=list(input())
r=0
for ii in range(len(s)-1):
  if s[ii+1]!=s[ii]:
    r+=1
print(r)

a=input()
b=0
for i in range(len(a)-1):
  if a[i]!=a[i+1]:
    b=b+1
print(b)

S=list(input())
c=0;m=''
for i in S:
    if i!=m:
        m=i
        c+=1
print(c-1)

# coding = SJIS

s = str(input())
ans = 0

for i in range(len(s) - 1):
    if s[i] != s[i + 1]:
        ans += 1

print(ans)

s = input()
ans = 0
for i in range(len(s)-1):
    if s[i]!=s[i+1]:
        ans += 1
print(ans)

import itertools
s = input()
print(len(list(itertools.groupby(s)))-1)

from itertools import groupby
S = input()
gr = groupby(S)
print((len(list(gr))-1))


S = str(input())
N = len(S)
D = [0,0] #B,W
ans = 0; prev = S[0]
for i in range(N):
  if S[i] == "B":
    D[0] += 1
  else:
    D[1] += 1
  if i >= 1:
    if S[i] == prev:
      continue
    else:
      ans += 1
      prev = S[i]
if D[0] == 0: #すべてW
  print((0)); return
elif D[1] == 0:
  print((0)); return
print(ans)


s = input()

s_ = s[0]

for c in s:
    if s_[-1]!=c:
        s_ += c
print(len(s_)-1)

# -*- coding: utf-8 -*-
"""
Created on Wed Sep 30 02:12:31 2020

@author: liang
"""

S = input()
ans = 0
for i in range(len(S) - 1):
    if S[i] != S[i+1]:
        ans += 1

print(ans)

s = input()
res = 0
for i in range(len(s) - 1):
  if s[i] != s[i+1]:
    res += 1
print(res)

S = input()
print(S.count("WB")+S.count("BW"))

s = input()

now = ""
ans = 0
for i in range(len(s)):
  if i == 0:
    now = s[0]
    continue
  if s[i] != now:
    ans += 1
    now = s[i]
print(ans)

s = input()
cnt = 0
cur = s[0]
strk = 1

for i in range(1, len(s)):
    if s[i] == cur:
        strk += 1
    else:
        cnt += 1
        cur = s[i]
        strk = 1

cnt += 1

print(cnt-1)

S=input()
i=1
l=len(S)
res=0
f=S[0]

while i<l:
  if (S[i] == f):
        i+=1
  else:
    res+=1
    f=S[i]
    i+=1
print(res)

S=input()
rest=S[0]
cnt=0
for i in range(1,len(S)):
    if S[i]!=rest:
        cnt+=1
        rest=S[i]
print(cnt)