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:
# C
S=list(input())
f=0
for i in range(len(S)-1):
    if S[i]!=S[i+1]:
        f+=1
print(f)

Submission status: Accepted

Solution code:
s = input()
ans = 0
chk = s[0]
if len(s) == 1:
    print(0)
    exit()
for i in range(1, len(s)):
    if s[i] == chk:
        pass
    else:
        ans += 1
        chk = s[i]
    #print(s[i], ans)
print(ans)

Submission status: Accepted

Solution code:
S = input()

ans = 0
# 前の石の色
before_color = ''

for i, char in enumerate(S):
    if i == 0:
        before_color = char
        continue
    
    # 同じ石の場合は次へ
    if char == before_color:
        continue
    
    # 違う色の場合は1回回数増える
    ans += 1
    before_color = char
    
print(ans)

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

Submission status: Accepted

Solution code:
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:
def c_1d_reversi():
    # 端の同じ色の石は1個の石を置けばひっくり返せる
    # 連続した石をひとまとめにしたとき，何個の石があるかが解
    from itertools import groupby
    return len(list(groupby(input()))) - 1

print(c_1d_reversi())

Submission status: Accepted

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

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

import math
main()

Submission status: Accepted

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

print(t)

Submission status: Accepted

Solution code:
def groupby(a):
    a2=[[a[0],1]]
    for i in range(1,len(a)):
        if a2[-1][0]==a[i]:
            a2[-1][1]+=1
        else:
            a2.append([a[i],1])
    return a2

s=groupby(input())
print(len(s)-1)

Submission status: Accepted

Solution code:
def main():
    board = input()
    answer = 0
    series = board[0]
    for b in board:
        if not series == b:
            series = b
            answer += 1
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
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=input()
cnt=0
n=len(s)
for i in range(n-1):
    if s[i]=='B' and s[i+1]=='W':
        cnt+=1
    elif s[i]=='W' and s[i+1]=='B':
        cnt+=1
print(cnt)

Submission status: Accepted

Solution code:
def I(): return int(input())
def MI(): return map(int, input().split())
def LMI(): return list(map(int, input().split()))
MOD = 10 ** 9 + 7


S = input()
cnt1 = 0
cur = S[0]
for c in S:
    if cur != c:
        cnt1 += 1
        cur = c

cnt2 = 0
cur = S[-1]
for c in reversed(S):
    if cur != c:
        cnt2 += 1
        cur = c

print(min(cnt1, cnt2))

Submission status: Accepted

Solution code:
S = input()
w = S.split('B')
w = [x for x in w if x != '']
b = S.split('W')
b = [x for x in b if x != '']

print(len(w)+len(b)-1)

Submission status: Accepted

Solution code:
import re

s = input()

s = re.sub(r"([BW])\1*(?!\1)", r"\1", s)

print(int(len(s) - 1))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
n = s[0]
count = 0
for i in s[1:]:
    if n != i:
        n = i
        count += 1

print(count)

Submission status: Accepted

Solution code:
s = input()

c = s[0]
m = 0

for i in s:
    if c != i:
        c = i
        m += 1
        
print(m)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#C - 一次元リバーシ

S = list(input())

first = S[0]

count = 0
for str in S:
  if str != first:
    count += 1
  first = str
  
print(count)

Submission status: Accepted

Solution code:
from collections import defaultdict
d = defaultdict(int)

S = input()
ans = 0
tmp = S[0]

for s in S:
  d[s] += 1

  if s != tmp:
    ans += 1

  tmp = s

if len(d) == 1:
  print(0)
else:
  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:
#!/usr/bin/env python3
import sys
INF = float("inf")


def Run_length_encoding(S: str):
    ans = []
    curr = S[0]
    counter = 0
    for c in S:
        if c == curr:
            counter += 1
        else:
            ans.append((curr, counter))
            curr = c
            counter = 1
    ans.append((curr, counter))
    return ans


def solve(S: str):
    rle = Run_length_encoding(S)
    print(len(rle)-1)
    return


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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(input())
x = s[0]
ansl = [s[0]]
for i in range(1,len(s)):
    
    if s[i] == x:
        pass
    else:
        ansl.append(s[i])
        x = s[i]
print(len(ansl)-1)

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

f = s[0]
ans = 0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
ans = 0

now = "?"
for s in S:
    if now == s:
        continue
    ans += 1
    now = s

print(ans-1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
s=input()
cur=s[0]
counter=1
for i,ss in enumerate(s):
    if i==0:
        continue
    if ss!=cur:
        counter+=1
        cur=ss
print(counter-1)

Submission status: Accepted

Solution code:
s=input()

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# 色が変わっている個数を数える
s = input()
cnt = 0
for i in range(len(s)-1):
    if s[i] != s[i+1]: cnt += 1
print(cnt)
"""
for i in range(len(s)-1):
    if s[i] != s[i+1]: cnt += 1
print(cnt)"""

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    S=ST()
    before = " "
    RLE = []
    for s in S:
        if before != s:
            RLE.append(s)
        before = s
    print(len(RLE)-1)


if __name__ == '__main__':
    main()
    # S=ST()
    # ans = 0
    # for i in range(len(S)):
    #     for it in combinations([i for i in range(len(S))], i):
    #         before = 0
    #         for j in it:
    #             print(int(S[before:j+1]), before,j)
    #             ans += int(S[before:j+1])
    #             before = j+1
    #         try:
    #             ans += int(S[before:])
    #         except:
    #             pass
    #         print(ans)
    # print(ans)

Submission status: Accepted

Solution code:
import sys
read=sys.stdin.readline

S=list(read())
del S[-1]

ans,buf=-1,''
for s in S:
    if buf!=s:
        ans+=1
        buf=s
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(input())

r = 0
color = s[0]
for stone in s:
  if stone != color:
    color = stone
    r += 1

print(r)

Submission status: Accepted

Solution code:
def run_length(data, init=''):
    length = []
    tmp = init
    cnt = 0
    for c in data:
        if tmp != c:
            length.append(cnt)
            cnt = 0
        tmp = c
        cnt += 1
    length.append(cnt)
    return length

s = input()
rev = run_length(s)
# print(rev)
print(len(rev) - 2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

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

S=one_str()

count=0
list_S = list(S)
old = list_S[0]
for i in range(1,len(list_S)):
    if old != list_S[i]:
        count+=1
    old = list_S[i]

print(count)

Submission status: Accepted

Solution code:
S = input()

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

print(ans)

Submission status: Accepted

Solution code:
def run_length(s) -> list:
  res = [[s[0], 1]]
  for i in range(1, len(s)):
    if res[-1][0] == s[i]:
      res[-1][1] += 1
    else:
      res.append([s[i], 1])
  return res

R = run_length(input())
print(len(R) - 1)

Submission status: Accepted

Solution code:
import re
s = input()
wb = re.findall("WB", s)
bw = re.findall("BW", s)
print(len(wb+bw))

Submission status: Accepted

Solution code:
S = input()
while "WW" in S:
  S = S.replace("WW", "W")
while "BB" in S:
  S = S.replace("BB", "B")
print(len(S)-1)

Submission status: Accepted

Solution code:
s = input()

c = []
f = s[0]
count = 1
for si in list(s):
  if f != si:
    count += 1
    c.append(count)
    f = si
  else:
    c.append(count)

stone_count = len(set(c))
if stone_count == 2:
  print(1)
  exit()

if stone_count == 1:
  print(0)
  exit()
  
print(stone_count - 1)

Submission status: Accepted

Solution code:
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 = input()
key = s[0]
count = 0
for i in range(1,len(s)):
    if key != s[i]:
        count += 1
        key = s[i]
print(count)

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

Submission status: Accepted

Solution code:

S = input()

ans = 0
tmp = None
for s in S:
  if tmp == None:
    tmp = s
  else:
    if tmp != s:
      ans += 1
      tmp = s

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
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=input()
current=S[0]
if len(S)==1:
    print(0)
else:
    cnt=0
    for w in S[1:]:
        if w==current:
            cnt+=0
        else:
            cnt+=1
        current=w
    print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

if sys.platform =='ios':
	sys.stdin=open('input_file.txt')
	
#+++++
s=list(input().strip())
count=0
prev=s[0]
for c in s[1:]:
	if c != prev:
		count += 1
		prev = c
print(count)

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

ans = 0
tmp = s[0]

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

print(ans)

Submission status: Accepted

Solution code:
S = input()

res=0
last_c=S[0]
for tmp in S:
    if tmp != last_c:
        res+=1
    last_c=tmp
print(res)

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

Submission status: Accepted

Solution code:
s = input()
c = 1
f = False

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

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


def main():
    S = input().strip()
    s = S[0]
    ans = 0
    for i in range(1, len(S)):
        if s != S[i]:
            ans += 1
            s = S[i]

    print(ans)




if __name__ == '__main__':
    main()

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:
BW=input()
BF=BW[0]
LS=[BW[0]]
for s in BW:
  if BF != s:
    LS.append(s)
    BF=s
print(len(LS)-1)

Submission status: Accepted

Solution code:
def solve(s):
    prev = ''
    count = 0
    for c in s:
        if prev != c:
            count += 1
        prev = c
    return count - 1

_s = input()
print(solve(_s))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
s = list(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=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:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    line = S()
    unique = line[0]
    for c in line:
        if c != unique[-1]:
            unique += c
    print(len(unique)-1)

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
s = str(s)
s = list(s)
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 = str(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 = str(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:
import sys
input = sys.stdin.readline
s=input().strip()
cnt=0
for i in range(1,len(s)):
    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()

count = 0
pre_s = None
for s in S:
    if s != pre_s:
        count += 1
        pre_s = s
print(count - 1)

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
cnt = 0
before = S[0]

for s in S:
    if s != before:
        cnt += 1
    before = s
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:
a=input()
n=len(a)
ans=0
for i in range(n-1):
    if a[i]!=a[i+1]:
        ans+=1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
word=input()
# word="WBWBWBWBWB"
ans=0
for i in range(len(word)-1):
    if word[i]!=word[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:
S = list(input())

before_color = S[0]
ans = 0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ABC047c
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
line = input()

count = -1
current = "hoge"
for c in line:
    if current != c:
        count += 1
        current = c

print(count)

Submission status: Accepted

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

for c in s:
    if c != st:
        ans += 1
        st = c

print(ans)

Submission status: Accepted

Solution code:
s = input()

count = 0

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

print(count)

Submission status: Accepted

Solution code:
s = input()
l = len(s)
tmp = 'a'
ans = 0
for i in range(l):
    if tmp != s[i]:
        ans += 1
        tmp = s[i]

print(ans-1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# import numpy as np
# import math
import sys
input = sys.stdin.readline

S = input()

N = len(S) - 1

numW = S.count('W')
numB = N - numW
if (numW == N) | (numW == 0):
    print(0)
    sys.exit()

res = 0
checked = 0

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

print(res)

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=list(input())

import itertools

S2=[k for k, v in itertools.groupby(S)]

print(len(S2)-1)

Submission status: Accepted

Solution code:
from itertools import groupby

S = groupby(input())
cnt = sum([1 for k, v in S])
print(cnt-1)

Submission status: Accepted

Solution code:
sl = list(input())

ans = 0
before = ""

for s in sl:
   if before == s:
      continue
   else:
      ans += 1
      before = s
   
print(ans-1)

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:
#047C 一次元リバーシ
import sys
S = sys.stdin.readline().rstrip()
#print(S)
n = len(S)
cnt =0
for i in range(n-1):
    if S[i] != S[i+1]:
        cnt +=1
print(cnt)

Submission status: Accepted

Solution code:
s = input()

pre = s[0]
ans = 0
for si in s:
  if pre != si:
    ans += 1
    pre = si

print(ans)

Submission status: Accepted

Solution code:
S = raw_input()

s = S
n = 0
while len(s):
    s = s.lstrip(s[0])
    if len(s):
        n += 1

print n

Submission status: Accepted

Solution code:
import sys
S = input()

N = len(S)

string = []
string.append(S[0])

for n in range(1, N):
    if S[n - 1] == S[n]:
        continue
    else:
        string.append(S[n])

print(len(string) - 1)

Submission status: Accepted

Solution code:
s = input()
ans = 0
now = s[0]
for i in range(1, len(s)):
    if now == "B":
        if s[i] == "W":
            ans += 1
            now = "W"
    else:
        if s[i] == "B":
            ans += 1
            now = "B"
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:
a = list(input())
s = -1
d = ''
for i in a:
    if i != d:
        s += 1
    d = i
print(s)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
S = list(input().rstrip())
N = len(S)
cnt = 0
for i in range(N-1):
    if S[i] != S[i+1]:
        cnt += 1
print(cnt)

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

print(answer)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
S = list(input())
i = 0
count = 0
while(i < len(S)-1):
  if S[i] != S[i+1]:
    count+=1
  i+=1
  
print(count)

Submission status: Accepted

Solution code:
s = input()

ans = 0
x = s[0]
for v in s[1:]:
    if v != x:
        ans += 1
        x = v

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

if sys.platform in ['ios','win32','darwin']:
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

S = input().rstrip()

A = [s for s in S]
B = []

now = -1
cur = 0
for i, a in enumerate(A):
	if now == -1:
		B.append(a)
		now = a
	if now != a:
		B.append(a)
		now = a

# print(B)

print(len(B)-1)

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:
from itertools import groupby

S = input()

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

Submission status: Accepted

Solution code:
s = list(input())

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

s = sys.stdin.readline().rstrip()

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

if __name__ == '__main__':
    ans = main()
    print(ans)

Submission status: Accepted

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