Problem:
 Score : 300 points    Problem Statement 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 1 BBBWW      Sample Output 1 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.       Sample Input 2 WWWWWW      Sample Output 2 0  If all stones are already of the same color, no new stone is necessary.       Sample Input 3 WBWBWBWBWB      Sample Output 3 9

Solution (Python):
S = input()

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

print(ans)

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

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

Solution (Python):
S = input()
s = S[0:1]
ans = 0

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

print(ans)

Solution (Python):
s = input()
c = 0
i = 0
l = len(s)
while i < l-1:
    if s[i] != s[i+1]:
        c += 1
    i += 1
print(c)

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

Solution (Python):
S = input()

ans = 0

pre = ' '
for c in S:
    if pre != ' ' and pre != c:
        ans += 1
    pre = c

print(ans)

Solution (Python):
import sys

S = str(input())

if (not "B" in S) or (not "W" in S):
    print(0)
    sys.exit()

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

Solution (Python):
S = input()
before = ""
r = 0
for i in range(len(S)):
    if i == 0:
        before = S[i]
    else:
        if before == S[i]:
            continue
        else:
            before = S[i]
            r += 1
print(r)

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

Solution (Python):
def main():
    s = input()
    c0 = s[0]
    res = 0
    for c in s:
        if c != c0:
            res += 1
            c0 = c
    print(res)


if __name__ == '__main__':
    main()

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

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

Solution (Python):





def c_1d_reversi(S):
    
    

    def unique_justseen(iterable, key=None):
        from itertools import groupby
        from operator import itemgetter
        return map(next, map(itemgetter(1), groupby(iterable, key)))

    ans = len(list(unique_justseen(S))) - 1
    return ans

S = input()
print(c_1d_reversi(S))

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

Solution (Python):
s = input()
ans = 0
while len(s):
    c = s[0]
    for i in range(len(s)):
        if s[i] != c:
            idx = i
            break
        idx2 = i
    if idx2 == len(s)-1:
        break
    s = s[idx:]
    ans += 1

print(ans)

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

Solution (Python):

S = input()

ans = 0
for i, Si in enumerate(S):
    if i == 0: view = Si
    else:
        if Si != view:
            ans += 1
            view = Si
        else:
            continue

print(ans)

Solution (Python):
S = input()

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

print(count)

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

Solution (Python):
S = input()
s = S[0]
l = 0
for i in range(1, len(S)):
    if s[-1] != S[i]:
        s += S[i]
        l += 1

print(l)

Solution (Python):
S = input()

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

print(len(s) - 1)

Solution (Python):
S = input()

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

print(len(s) - 1)

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

Solution (Python):
S = input()
now = S[0]
ans = 0
for s in S[1:]:
    if not s == now:
        now = s
        ans += 1
print(ans)

Solution (Python):
import re
s = input()
s= re.sub("B+","B",s)
s= re.sub("W+","W",s)
print(len(s)-1)

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

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

Solution (Python):
S = input()
s = list(S)

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

Solution (Python):

S = input()

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

print(ans)

Solution (Python):
S = input()
x = S[0]
cnt = 0
for c in S[1:]:
    if x == c: continue
    cnt += 1
    x = c
print(cnt)

Solution (Python):
s = input()
tmp = s[0]
ans = 0

for si in s:
    if si != tmp:
        ans += 1
        tmp = si
print(ans)

Solution (Python):
a = list(input())
x = 0

for i in range(len(a)):
  if i == len(a)-1:
    break
  if a[i] != a[i+1]:
    x += 1
  
    
print(x)

Solution (Python):
L = list(input())
ans = 0
for i in range(len(L)) :
    if i == 0 :
        p = L[0]
    else :
        if L[i] != p :
            p = L[i]
            ans += 1
print(ans)

Solution (Python):
s = input()
last = s[0]
cnt = 0
for ch in s:
  if last != ch:
    cnt += 1
    last = ch
print(cnt)

Solution (Python):
def main():
    s = input()
    y = s[0]
    c = 0

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

main()

Solution (Python):


s = list(input())
count = 0

if s.count('W') == len(s) or s.count('B') == len(s):
    print('0')
else:
    turn = s[len(s) - 1]
    s.pop()
    while s:
        if s[len(s) - 1] == turn:
            s.pop()
        else:
            count += 1
            if turn == 'B':
                turn = 'W'
            else:
                turn = 'B'
    print(count)

Solution (Python):
s = list(input())
count = 0

now = s[0]
for i in range(1, len(s)):
    if now == s[i]:
        count += 1
    else:
        now = s[i]

print(len(s) - count - 1)

Solution (Python):
def solve(s):
    return s.count("BW") + s.count("WB")


if __name__ == "__main__":
    print(solve(input()))

Solution (Python):

S = list(input())

S2 = []
S2.append(S[0])
for i in range(1,len(S)):
    if S[i-1] != S[i]:
        S2.append(S[i])
    else:
        pass


print(len(S2)-1)

Solution (Python):


import sys


input = sys.stdin.readline


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


S = input().rstrip()

curr = S[0]
cnt = 0
for s in S:
    if s != curr:
        cnt += 1
        curr = s

print(cnt)

Solution (Python):
s = input()
print(sum([1 for i in range(1, len(s)) if s[i-1] != s[i]]))

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

Solution (Python):
from itertools import groupby as g
print(len(list(g(input())))-1)

Solution (Python):
from itertools import groupby

s = input()
g1 = groupby(s)
g2 = groupby(s[::-1])
res = float('inf')

for i in [g1,g2]:
    cnt = 0
    for k,v in i:
        cnt += 1
    res = min(res,cnt-1)
print(res)

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

Solution (Python):

from sys import stdin

s = stdin.readline().rstrip()
ans = 0

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

Solution (Python):
S = list(input())
flag = S[0]
flag_num = 0
ans = 0


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

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

Solution (Python):
S=input()

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

Solution (Python):
sS = input().rstrip()

ic = 0
ts = sS[0]
for s in sS:
    if s != ts:
        ts = s
        ic += 1
print(ic)

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

Solution (Python):
S = input()

cnt = 0
tmp = S[0]

for s in S:
    if s != tmp:
        cnt += 1
        tmp = s
print(cnt)

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

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

Solution (Python):
S = input()
count = 0
if not "B" in S or not "W" in S:
  print(count)
else:
  for i in range(len(S)-1):
    if S[i] != S[i+1]:
      count += 1
  print(count)

Solution (Python):
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    S = input()

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

    print(len(T) - 1)


if __name__ == '__main__':
    main()

Solution (Python):
S = input()
reverse = 0
current = S[0]
for i in range(1, len(S)):
    if S[i] != current:
        reverse += 1
        current = S[i]

print(reverse)

Solution (Python):



s = input()
ans = 0
color = s[0]
for si in s[1:]:
    if color != si:
        color = si
        ans += 1

print(ans)

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

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

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

Solution (Python):
S = input()

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

Solution (Python):
input_s = input()

cnt  = 0
prev = input_s[0] 
for s in input_s[1:]:
    if prev != s:
        prev = s
        cnt += 1

print(cnt)

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

Solution (Python):
S = input()

count = 0

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

print(count)

Solution (Python):
s=input()
bflag=0
wflag=0
if s[0]=="B":
    bflag=1
else:wflag=1
count=0
for i in s[1:]:
    if i=="B" and wflag==1:
        count+=1
        wflag=0
        bflag=1
    elif i=="W" and bflag==1:
        count+=1
        wflag=1
        bflag=0
print(count)

Solution (Python):
S = input()
if len(set(S)) == 1:
    print(0)
else:
    count = 0
    color = S[0]
    for i in range(1, len(S)):
        if S[i] != color:
            color = S[i]
            count += 1
    print(count)

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

Solution (Python):
s = input()

count = 0

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

print(count)

Solution (Python):
s = input()
c = list(s)

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

print(ans)

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

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

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

Solution (Python):
S = input()

c, ans = S[0], 1
for s in S:
    if s != c:
        ans += 1
        c = s
print(ans - 1)
exit(0)

Solution (Python):

def main():
    s = input()


    ans = 0
    now = ""
    for i in s:
        if now != i:
            ans +=1
            now = i

    print(ans -1)




if __name__ == "__main__":
        main()

Solution (Python):
S = input()

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

Solution (Python):
N=input()
switch=0
which=N[0]
for i in range (1,len(N)):
    if N[i]!=which:
        switch+=1
        which=N[i]
print (switch)

Solution (Python):
import sys
import math
import collections
import itertools
import array
import inspect


sys.setrecursionlimit(1000000)



def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))



def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v



def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk



def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


class Combination:
    def __init__(self, n, mod):

        g1 = [1, 1]
        g2 = [1, 1]
        inverse = [0, 1]
        for i in range(2, n + 1):
            g1.append((g1[-1] * i) % mod)
            inverse.append((-inverse[mod % i] * (mod // i)) % mod)
            g2.append((g2[-1] * inverse[-1]) % mod)
        self.MOD = mod
        self.N = n
        self.g1 = g1
        self.g2 = g2
        self.inverse = inverse

    def __call__(self, n, r):
        if (r < 0 or r > n):
            return 0
        r = min(r, n - r)
        return self.g1[n] * self.g2[r] * self.g2[n - r] % self.MOD




dp = None


def main():
    S = input()

    pre_s = S[0]
    ans = 0

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

    print(ans)


main()

Solution (Python):
S=str(input())
T=[]
for i in range(len(S)):
    if i==0:
        T.append(S[i])
    elif S[i]!=S[i-1]:
        T.append(S[i])
print(len(T)-1)

Solution (Python):
s = input()

s = s[0] + s

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

Solution (Python):
import itertools
print(len(list(itertools.groupby(input())))-1)

Solution (Python):


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

if __name__ == '__main__':
    main()

Solution (Python):

"""
Created on Sun Aug 12 14:17:46 2018
ABC047C
@author: maezawa
"""

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

print(cnt)

Solution (Python):
s = input()

s = s[0] + s

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

Solution (Python):
s, ans = raw_input(), 0
for i in range(len(s) - 1):
    if (len(set(s[i : i + 2])) == 2):
        ans += 1
print ans

Solution (Python):
s, ans = raw_input(), 0
for i in range(len(s) - 1):
    if (len(set(s[i : i + 2])) == 2):
        ans += 1
print ans

Solution (Python):
cnt = 0
S = input()
for i in range(len(S) - 1):
    if len(set(S[i:i + 2])) == 2:
        cnt += 1

print(cnt)

Solution (Python):
s = input()
if s == "W" * len(s):
    print(0)
elif s == "B" * len(s):
    print(0)
else:
    if s == "B" + "W" * (len(s) - 1):
        print(1)
    else:
        num = 0
        k = 1
        if s[0] == "B":
            num += 1
            while s[k] == "B":
                k += 1
        pre = "W"

        for i in range(k, len(s)):
            if pre != s[i]:
                num += 1
            pre = s[i]
        print(num)

Solution (Python):
def getinputdata():

    
    array_result = []
    
    data = input()
    
    array_result.append(data.split(" "))

    flg = 1

    try:

        while flg:

            data = input()
            if(data != ""):
                
                array_result.append(data.split(" "))

            else:

                flg = 0
    finally:

        return array_result

arr_data = getinputdata()

s = arr_data[0][0]

cnt=0
posi=0
    
while s.find("BW",posi)>=0 or s.find("WB",posi)>=0:

    if s.find("BW",posi)>=0 and s.find("WB",posi)>=0 :
        
        posi=min(s.find("BW",posi),s.find("WB",posi))+1
    
    elif s.find("BW",posi)>=0 and s.find("WB",posi)==-1 :
        
        posi=s.find("BW",posi)+1
        
    elif s.find("BW",posi)==-1 and s.find("WB",posi)>=0 :
        posi=s.find("WB",posi)+1
        
    cnt+=1
        
print(cnt)

Solution (Python):
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)

Solution (Python):
s = input()
ans = 0
for i, elem in enumerate(s):
    if i == 0:
        continue
    if s[i-1] != elem:
        ans += 1
print(ans)

Solution (Python):
s = input()
if s[0] == 'W':
    ans = s.count('WB')
elif s[0] == 'B':
    ans = s.count('BW')
if s[0] == s[len(s) - 1]:
    a = 1
else:
    a = 0
print(0 if ans==0 else ans * 2 - 1 + a)

Solution (Python):
S = input()

abv_list = []
prev_c = ""

for c in list(S) :
    if len(abv_list) == 0 :
        abv_list.append(c)
        prev_c = c
    else :
        if c != prev_c :
            abv_list.append(c)
        prev_c = c
    
print(0 if len(abv_list) == 1 else abv_list.count('B') + abv_list.count('W') - 1)

Solution (Python):
s=input()
if s[0]=='W':
    ans=s.count('WB')
elif s[0]=='B':
    ans=s.count('BW')
if s[0]==s[len(s)-1]:
    a=1
else:
    a=0
    
if ans==0:
    print(0)
else:
    
    print(ans*2-1+a)

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

Solution (Python):
S = input()
re = 0
b = S[0]
for s in S:
    if not b == s:
        re += 1
    b = s
print(re)

Solution (Python):
l = list(input())
op = 0
s_p = l[0]
for i, s in enumerate(l[1:], start=1):
    if s == s_p:
        continue
    else:
        s_p = s
        op += 1
print(op)

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

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

Solution (Python):
S = input()

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

Solution (Python):


S = input()

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

Solution (Python):
import re

S = input()

print(len(re.findall('B+', S)) + len(re.findall('W+', S)) - 1)

Solution (Python):
import re

S = input()

x = S[0]
y = S[-1]

cnt = {}
cnt['B'] = len(re.findall('B+', S))
cnt['W'] = len(re.findall('W+', S))

if x == y:
  print(2 * (cnt[y]-1))
  
else:
  print(min(2 * cnt[x] -1, 2 * cnt[y] -1))

Solution (Python):
w=list(input())

n=len(w)

c=0

for i in range(n-1):
    if not w[i]==w[i+1]:
        c+=1

print(c)

Solution (Python):
s = input()

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

Solution (Python):
s = input()

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

print(count)

Solution (Python):
S = input()

S_list = list(S)

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

Solution (Python):
s = input()

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

print(ans)

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

Solution (Python):
s = input()

flip_count = 0
prev = s[0]

for c in s:
  if c == prev:
    continue
  else:
    flip_count += 1
  prev = c

print(flip_count)

Solution (Python):
s = input()
print(s.count('WB') + s.count('BW'))

Solution (Python):
s = raw_input()
diff = 0
for i in range(len(s)-1):
  if s[i+1] != s[i]:
    diff += 1
print(diff)

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

Solution (Python):
from itertools import groupby
S = input()
G = groupby(S)
print(len(list(G))-1)

Solution (Python):
str = input()
flag = str[0]
count=0
for i in str:
    if not(flag==i):
        flag=i
        count +=1

print(count)

Solution (Python):

print((lambda x:x.count('WB')+x.count('BW'))(input()))

Solution (Python):
S = input()
i = 0
ans = 0
while i < len(S)-1:
  if S[i] != S[i+1]:
    ans += 1
    i += 1
  else:
    i += 1
print(ans)

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

Solution (Python):
from collections import Counter
S = input()
ans = 0
c = Counter(S)
if c['W'] == 0 or c['B'] == 0:
    print(0)
    exit()
a = S[0]
while True:
    for i, s in enumerate(S):
        if s != a: break
    S = S[i:]
    c[a] -= i
    a = S[0]
    ans += 1
    if c['W'] == 0 or c['B'] == 0:break
print(ans)

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

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

Solution (Python):
s = raw_input()
n = len(s)
i = 1
now = s[0]
count = 0
while i < n:
	if s[i] != now:
		now = s[i]
		i += 1
		count += 1
	else:
		i += 1

print count

Solution (Python):
def m():
    s = str(input())
    cnt = 0
    tmp = s[0]
    for i in s:
        if tmp != i:
            tmp = i
            cnt += 1
    return cnt
    pass

print(m())

Solution (Python):
s=input();print(s.count('WB')+s.count('BW'))

Solution (Python):
s=input();print(sum([0,1][s[i]!=s[i-1]]for i in range(1,len(s))))

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

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

Solution (Python):
def main():
    S = input()

    b = sum(1 for x in S.split("W") if x.startswith("B"))
    w = sum(1 for x in S.split("B") if x.startswith("W"))
    ans = b + w - 1

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):





if __name__ == '__main__':
    s = input()
    count = 0

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

    print(count)

Solution (Python):





if __name__ == '__main__':
    s = input()
    count = 0
    previous = s[0]

    for i in range(1, len(s)):
        current = s[i]

        if previous != current:
            count += 1

        previous = current

    print(count)

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

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

Solution (Python):
s = list(input().rstrip())

ans = 0

p_c = s.pop(0)
while s:
    c = s.pop(0)
    if p_c != c:
        ans += 1
    p_c = c
print(ans)

Solution (Python):
def main():
    s = input()
    
    cnt = 0
    for i in range(1, len(s)):
        if s[i] != s[i-1]:
            cnt += 1
            
    print(cnt)
    
    
if __name__ == "__main__":
    main()

Solution (Python):
l = list(input())
now = l[0]
count = 0
for i in range(1, len(l)):
  if not l[i] == now:
    count += 1
    now = l[i]

print(count)

Solution (Python):
S = input()

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

Solution (Python):
S = input()
n = S[0]
ans = 0
for k in range(1,len(S)):
    if n != S[k]:
        ans += 1
        n = S[k]
print(ans)

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

Solution (Python):
s=list(input())
sl=len(s)
cnt=0
for i in range(sl-1):
    if s[i]=="W":
        if s[i+1]=="B":
            cnt+=1
    elif s[i]=="B":
        if s[i+1]=="W":
            cnt+=1
print(cnt)

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

Solution (Python):
s = list(str(input()))
t = s[-1]
s.append(t)

flag = 0
for i in range(len(s) -1):
    p = s[i]
    q = s[i + 1]
    if p != q:
        flag=flag+ 1
print(flag)

Solution (Python):
def main():
    S = input()

    reversi = S
    while 1:
        before = reversi
        reversi = reversi.replace('BB', 'B')
        reversi = reversi.replace('WW', 'W')
        if reversi == before:
            break
    print(len(reversi) - 1)

main()

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

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

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

Solution (Python):
x=0
n=0
f='X'
for j in list(input().strip()):
  if n!=0 and f != j:
    x += 1  
  f = j
  n += 1
print(x)

Solution (Python):
s = input()
asso = 1
c = s[0]
for i in range(1,len(s)):
    if not s[i]==c:
        c = s[i]
        asso += 1
print(asso-1)

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

Solution (Python):
l = list(input())
now = l[0]
count = 0

for i in range(1, len(l)):
  if not now == l[i]:
    count += 1
    now = l[i]

print(count)

Solution (Python):
def solve():
    S = input()
    ans = 0
    for i, stone in enumerate(list(S)):
        if i >= len(S) - 1:
            break
        if not stone == S[i + 1]:
            ans += 1
    print(ans)

solve()

Solution (Python):
s = input()
cnt = 0
tmp = s[0]

for i in s:
    if i != tmp:
        cnt += 1
        tmp = i

print(cnt)

Solution (Python):
str = list(input())
out = 0
pro = str[0]
for i in range(len(str)):
    if pro != str[i]:
        out += 1
    pro =str[i]

print(out)

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

Solution (Python):
S = input()
rev = []
prev = ''
for i in range(len(S)):
  if prev != S[i]:
    prev = S[i]
    rev.append(prev)
print(len(rev)-1)

Solution (Python):
def reversi(s):
    count = 0
    for i in range(1, len(s)):
        if s[i-1] != s[i]:
            count += 1
    return count


if __name__ == '__main__':
    s = input()
    print(reversi(s))

Solution (Python):
def reversi(stones):
    s = list(stones)
    count = 0
    previous = s[-1]
    while s:
        current = s.pop()
        if current != previous:
            count += 1
            previous = current
    return count


if __name__ == '__main__':
    s = input()
    print(reversi(s))

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

Solution (Python):
s = list(input())
tmp_s = s.pop(0)

count = 0
for i in s:
    if tmp_s != i:
        count += 1
        tmp_s = i
print(count)

Solution (Python):
S = input()
prev = S[0]
cnt = 1
for i in range(len(S)):
	if prev != S[i]:
		cnt += 1
		prev = S[i]

print(cnt - 1)

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

Solution (Python):
s = input()
a = s[0]
cnt = 0
for i in s:
    if i != a:
        cnt+=1
        a = i

print(cnt)

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

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

Solution (Python):
s=input()
count=1
for i in range(len(s)-1):
    if s[i]=="B":
        if s[i+1]=="W":
            count+=1
    elif s[i]=="W":
        if s[i+1]=="B":
            count+=1
print(count-1)

Solution (Python):
S = input().strip()
stone = S[0]
ans = 0
for i in range(1,len(S)):
  if stone != S[i]:
    ans += 1
    stone = S[i]
print(ans)

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

Solution (Python):
S = input()
kukan = 0

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

print(kukan)

Solution (Python):
S = input()
WB = []
x = S[0]
wb = ""

for s in S:
    if s == x:
        wb += s
    else:
        WB.append(wb)
        wb = s
        x = s
WB.append(wb)
print(len(WB) - 1)

Solution (Python):
def solve():
    S = list(input())
    cnt = 0
    for i in range(len(S) - 1):
        if S[i + 1] != S[i]:
            cnt += 1

    print(cnt)



solve()

Solution (Python):
S=raw_input()
cnt=0
c=""
for ind,i in enumerate(S):
	if ind==0:
		c=i
	else:
		if c!=i:
			cnt+=1
			c=i

print cnt