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



Sample input:
BBBWW


Sample output:
1

Submission status: Accepted

Solution code:
s = input()
cnt = 0
for i in range(len(s) - 1):
    if s[i] == 'W' and s[i + 1] == 'B':
        cnt += 1
    if s[i] == 'B' and s[i + 1] == 'W':
        cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
bw=input()
ans=0

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

Submission status: Accepted

Solution code:
s = input()
n = len(s)
ans = 0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

tmp = 0
Sd = []
while tmp < len(S):
    c = S[tmp]
    l = 0
    while c == S[tmp+l]:
        l += 1
        if tmp+l == len(S): break
    Sd.append((c,l))
    tmp += l

print(len(Sd)-1)

Submission status: Accepted

Solution code:
s=input()
c=0
for i in range(len(s)-1):
  if s[i:i+2]=='BW' or s[i:i+2]=='WB':c+=1
print(c)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
seiri=[]
for i in range(len(s)):
    if i==0:seiri.append(s[0])
    elif s[i]!=mae:seiri.append(s[i])
    mae=s[i]
print(len(seiri)-1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

cur = S[0]
ans = 0
for x in S[1:]:
    if x == cur:
        continue
    cur = x
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
s = input().strip()

prev = None
ans1, ans2 = 0, 0
for _s in s:
  if prev is None:
    prev = _s
  elif prev != _s:
    ans1 += 1
    prev = _s
prev = None
for _s in s[::-1]:
  if prev is None:
    prev = _s
  elif prev != _s:
    ans2 += 1
    prev = _s
print(min(ans1, ans2))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

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

print(ans)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
import sys
# N,M = [int(n) for n in input().split()]
S = str(input())
# T = 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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ans = len(list(more_itertools.unique_justseen(S))) - 1
# としたいが、more_itertoolsは入っていないみたいなので、
# https://github.com/erikrose/more-itertools/blob/master/more_itertools/recipes.py
# にある実装を流用している

def c_1d_reversi(S):
    # 端の同じ色の石は1個の石を置けばひっくり返せる
    # 連続した石をひとまとめにしたとき、何個の石があるかが解を導く

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# encoding: utf-8
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
S = input()

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

print(len(s) - 1)

Submission status: Accepted

Solution code:
S = input()

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

print(len(s) - 1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
# input
S = input()

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

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

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

main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8

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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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


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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
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(S2)
print(len(S2)-1)

Submission status: Accepted

Solution code:
# coding:utf-8

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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=input()

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

cnt = 0
tmp = S[0]

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

Solution code:
input_s = input()

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

print(cnt)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
S = input()

count = 0

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

print(count)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

count = 0

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

print(count)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

Solution code:

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

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
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))


# Binary converter
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


# Width First Search (+ Distance)
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


# Depth First Search (+Distance)
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()

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
#-*-coding:utf-8-*-

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
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)

Submission status: Accepted

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

Submission status: Accepted

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

print(cnt)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)
    print(ans*2-1+a)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

S = input()

cnt = 0
for i in range(1, len(S)):
    # ひとつ前と一致しない場所(白黒の境界)を数える
    if S[i] != S[i-1]:
        cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
import re

S = input()

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

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
s = input()

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

print(count)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

print(count)

Submission status: Accepted

Solution code:
# coding: utf-8
print((lambda x:x.count('WB')+x.count('BW'))(input()))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem C

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

    # See:
    # https://beta.atcoder.jp/contests/abc047/submissions/1007244
    for i in range(len(s) - 1):
        if s[i] != s[i + 1]:
            count += 1

    print(count)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem C

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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)