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: EASY

Solutions:
S = input()
ans = len([1 for (a, b) in zip(S, S[1:]) if a != b])
print(ans)


S = input()
print(len([0 for (index, c) in enumerate(S[1:], 1) if c != S[index - 1]]))


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


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


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


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


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


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


S = input() + 'x'
c = 'x'
cnt = 0
for s in S:
	cnt += s != c
	c = s
print(cnt - 2)


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()


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


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


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


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


S = input()
ANS = 0
for i in range(1, len(S)):
	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 = input()
N = len(S)
K = 0
for i in range(1, N):
	if S[i - 1] != S[i]:
		K += 1
print(K)


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


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


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


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


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()


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


s = input()
color = 'chokudai'
d = []
for c in s:
	if c != color:
		d.append(c)
		color = c
print(len(d) - 1)


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


s = input()
print(sum((a != b for (a, b) in zip(s, s[1:]))))


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


from itertools import groupby

def runLengthEncode(S: str):
	grouped = groupby(S)
	res = []
	for (k, v) in grouped:
		res.append((k, str(len(list(v)))))
	return res

def runLengthDecode(L: 'list[tuple]'):
	res = ''
	for (c, n) in L:
		res += c * int(n)
	return res

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 = input()
print(sum((c != d for (c, d) in zip(s, s[1:]))))


from itertools import groupby as gb
s = list(input())
g = gb(s)
print(len(list(g)) - 1)


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


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


from itertools import *
print(len([k for (k, g) in groupby(input())]) - 1)


S = input()
w = S[0]
c = 0
for a in S:
	if a != w:
		c += 1
		w = a
print(c)


S = str(input())
n = 0
ch = S[0]
for s in S:
	if ch != s:
		n += 1
	ch = s
print(n)


S = list(input())
T = S[0]
c = 0
for s in S:
	if T != s:
		c += 1
		T = s
print(c)


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


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


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


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


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()
c = 0
X = s[0]
for x in s:
	if X != x:
		c += 1
		X = x
print(c)


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


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


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


s = input()
a = [s[0]]
p = s[0]
for x in s:
	if x != p:
		a.append(x)
	p = x
print(len(a) - 1)


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


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()
t = S[0]
c = 0
for s in S:
	if s != t:
		c += 1
	t = s
print(c)


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


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


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


a = list(input())
s = -1
d = ''
for i in a:
	if i != d:
		s += 1
	d = i
print(s)


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


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


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


s = list(input())
a = s[0]
c = 0
for x in s:
	if a != x:
		a = x
		c += 1
print(c)


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


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)


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 = list(input())
a = s[0]
ans = 0
for i in s:
	if i != a:
		ans += 1
		a = i
print(ans)


S = input()
ans = len(S)
now = S[0]
for s in S:
	ans -= s == now
	now = s
print(ans)


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


s = input()
ans = 0
for (s1, s2) in zip(s, s[1:]):
	if s1 != s2:
		ans += 1
print(ans)


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


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


S = list(input())
import itertools
S2 = [k for (k, v) in itertools.groupby(S)]
print(len(S2) - 1)


S = input()
c = 0
bs = '_'
for s in S:
	if s != bs:
		c += 1
		bs = s
print(c - 1)


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


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


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


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


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


S = input()
print(len([0 for (c1, c2) in zip(S[:-1], S[1:]) if c1 != c2]))


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


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


from math import gcd
from itertools import combinations, permutations, accumulate, product
from collections import deque, defaultdict, Counter
import decimal
import re
import math
import bisect
import heapq
import sys
sys.setrecursionlimit(10000000)
mod = 10 ** 9 + 7
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()
c = 0
for k in range(1, len(S)):
	if S[k - 1] != S[k]:
		c += 1
print(c)


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


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


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


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


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


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


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


s = input()
temp = s[0]
ans = 0
for l in s:
	if temp != l:
		ans += 1
	temp = l
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)


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


S = input()
count = 0
p = ''
for s in S:
	if s != p:
		p = s
		count += 1
print(count - 1)


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


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


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


s = list(input())
ans = 0
x = s[0]
for t in s:
	if x != t:
		ans += 1
		x = t
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)


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


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)


import sys

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

def main():

	def iterate_tokens():
		for line in sys.stdin:
			for word in line.split():
				yield word
	tokens = iterate_tokens()
	S = next(tokens)
	print(solve(S))

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

def __starting_point():
	main()
__starting_point()


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()
l = [0 if s[i] == s[i + 1] else 1 for i in range(len(s) - 1)]
print(sum(l))


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


import os
import sys
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()


from itertools import groupby
print(len([k for (k, v) in groupby(input())]) - 1)


from itertools import groupby
S = input()
s = [i for (i, j) in groupby(S)]
print(len(s) - 1)


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


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


s = input()
ans = []
pre = ''
for i in s:
	if pre != i:
		ans.append(i)
		pre = i
print(len(ans) - 1)


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


s = input()
ans = 0
for (a, b) in zip(s[:-1], s[1:]):
	ans += a != b
print(ans)


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


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


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 as g
print(len(list(g(input()))) - 1)


s = input()
l = list(s[0])
for i in s:
	if i != l[-1]:
		l.append(i)
print(len(l) - 1)


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


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


S = input()
print(sum([1 for (x, y) in zip(S[:-1], S[1:]) if x != y]))


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


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


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


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


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(len(rle) - 1)
__starting_point()


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


[print(len(list(i.groupby(input()))) - 1) for i in [__import__('itertools')]]


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


S = input()
ans = 0
for (a, b) in zip(S, S[1:]):
	if a != b:
		ans += 1
print(ans)


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


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()
p = 0
for i in range(len(s) - 1):
	if s[i] != s[i + 1]:
		p += 1
print(p)


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


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


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


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


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


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)


s = list(input())
a = s[0]
s.remove(a)
c = 0
for i in s:
	if a != i:
		c += 1
	a = i
print(c)


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


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


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


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


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


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


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():
	resolve()
__starting_point()


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


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


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


s = input()
ans = 0
for (x, y) in zip(s, s[1:]):
	if x != y:
		ans += 1
print(ans)


import sys

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

def main():

	def iterate_tokens():
		for line in sys.stdin:
			for word in line.split():
				yield word
	tokens = iterate_tokens()
	S = next(tokens)
	print(solve(S))

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

def __starting_point():
	main()
__starting_point()