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

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()
while s!=s.replace('BB','B').replace('WW','W'):
  s=s.replace('BB','B').replace('WW','W')
print(len(s)-1)

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    from itertools import groupby
    print(len(list(groupby(input())))-1)
resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
  raw = raw_input()
  s = raw[0]
  for x in xrange(1, len(raw)):
      if raw[x] == s[-1]:
          continue
      s += raw[x]
  print(len(s)-1)


main()

Submission status: Accepted

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


if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
s = input()
l = len(s)
i =0
while s != 'W' * (l) and s != 'B' * (l):
    x = s[0]
    if x == 'B':
        k = s.find('W')
        s = s[k:]
    else:
        k = s.find('B')
        s = s[k:]
    i += 1
    l = len(s)
print(i)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(c)

Submission status: Accepted

Solution code:

import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
# A = [ int(input()) for _ in range(N) ]
##############################

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

Submission status: Accepted

Solution code:
def f():
    global s
    if s[-1] == x:
        return
    s = s[:-1]
    return f()

s = input()
ans = 0
while s and not s =="W"*len(s) and not s == "B"*len(s):
    if   s[-1] == "W":
        x = "B"
        y = "W"
    elif s[-1] == "B":
        x = "W"
        y = "B"
    f()
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
S = input()
N = len(S)

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

Submission status: Accepted

Solution code:
S = list(input())
ans, i, temp = 0, 1, S[0]
while i < len(S):
    if S[i] != temp:
        ans += 1
        temp = S[i]
    i += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
a = []
for i in range(len(s)):
  if i<len(s)-1 and s[i] == s[i+1]:
    pass
  else:
    a.append(s[i])
print(len(a)-1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

def main():
    s = input().strip()

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



if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
s=input()
A=[]
p=s[0]
for i in range(1,len(s)):
	if p!=s[i]:
		A.append(p)
		p=s[i]

A.append(s[-1])

print(len(A)-1)

Submission status: Accepted

Solution code:
s = input()
print(sum(s[i] != s[i + 1] for i in range(len(s)-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()
result=0
for i in range(len(S)-1):
  state=S[i]
  if S[i]!=S[i+1]:
    result+=1
  else:
    pass
print(result)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
t, ans = "", 0
for s in input():
    if t != s:
        ans += 1
        t = s
else:
    print(ans - 1)

Submission status: Accepted

Solution code:
S=input()
N=len(S)
crt=S[0]
cnt=0
for i in range(N-1):
    if crt!=S[i+1]:
        cnt+=1
        crt='B' if crt=='W' else 'W'
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 = list(input())

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

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from collections import Counter

stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

mod = 10 ** 9 + 7

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

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

Submission status: Accepted

Solution code:
from collections import deque
q = deque([])
S = input()
p = ''
for s in S:
  if s != p:
    q.append(s)
    p = s

print(len(q) - 1)

Submission status: Accepted

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

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

ans = section - 1
print(ans)

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc047/tasks/arc063_a
# C - 一次元リバーシ / 1D Reversi

S = input().split()[0]
before = S[0]
work_list = [S[0]]

for s in S[1:]:
    if s != before:
        work_list.append(s)
        before = s

ans = len(work_list) - 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
n=len(s)
count=0
if n==1:
  print(0)
  exit()
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,j in zip(s[:-1],s[1:]):
    if i!=j:
        ans+=1
print(ans)

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:
def main():
    S = input()
    if len(S) == 0: return 0

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

if __name__ == '__main__':

    print(main())

Submission status: Accepted

Solution code:
s=list(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:
# https://atcoder.jp/contests/abc047/tasks/arc063_a
import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    s = input()
    if len(s) == 0 or s.count('W') == 0 or s.count('B') == 0:
        print(0)
        return

    pre = s[0]

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    S = input()
    ws = S.split("W")
    w_cnt = 0
    bs = S.split("B")
    b_cnt = 0
    
    flg = True
    for i in ws:
        if i != "":
            flg = False
            w_cnt += 1
            
    if flg == True:
        print(0)
        sys.exit()
        
    flg = True
    for i in bs:
        if i != "":
            flg = False
            b_cnt += 1
    
    if flg == True:
        print(0)
        sys.exit()
        
    ans = (b_cnt + w_cnt) - 1
    print(ans)
    
    
if __name__ == "__main__":
	main()

Submission status: Accepted

Solution code:
import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7




n = input()

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



print(cnt)

Submission status: Accepted

Solution code:
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-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 _pf(s): return print(s, flush=True)

S = input()

if len(set(S)) == 0:
    print(0)
    exit()


"""
WWBBBWBBBBW

右から行くと、4
左から行くと、4

どちらからいってもおなじか？

WBWBWBWBWB
右から->9
左から->9
どちらからいってもかわらない？

右左両方から行く場合
WWBBBWBBBBW
WWBBBBWBW

WB, BWの数を数える？

"""
ans = 0

ans += S.count("WB")
ans += S.count("BW")

print(ans)

Submission status: Accepted

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

p = ''
tmp = ''
for s in S:
    if s != tmp:
        p += s
    tmp = s

print(len(p) - 1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
for i, c in enumerate(s) :
    if i == 0 :
        zipped = c
        cache = c
    elif cache != c :
        zipped += c
        cache = c
print(len(zipped)-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=list(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:
W = 0
B = 1
S = [W if c == 'W' else B for c in input().strip()]
N = len(S)
c = S[0]
answer = 0
for i in range(1,N):
    if c != S[i]:
        answer += 1
        c = S[i]
print(answer)

Submission status: Accepted

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

Submission status: Accepted

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

def runLength(s):
    a = []
    for c in s:
        if len(a)==0 or a[-1][0]!=c:
            a.append([c,1])
        else:
            a[-1][1] += 1
    return a
s = input().strip()
a = runLength(s)
print(len(a)-1)

Submission status: Accepted

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

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

import collections
import itertools
import sys
import time

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

if len(s) == 1:
  print(0)
  exit()

left = 0
right = 0

count = 0
while True:
  if s[right+1] != s[left]:
    count += 1
    right += 1
    left = right
    if right == len(s) - 1:
      break
  else:
    right += 1
    if right == len(s) - 1:
      break

print(count)

Submission status: Accepted

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

while "BB" in board:
    board = board.replace("BB", "B")
while "WW" in board:
    board = board.replace("WW", "W")

print(len(board)-1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 2019/08/08

s=input()
BW='B' if s[0]=='B' else 'W'
cnt=0

for i in range(len(s)):
    if s[i]==BW:continue
    BW=s[i]
    cnt+=1
print(cnt)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, math, fractions, itertools


def solve(S: str):
    tmp = S[0]
    counter = 0
    for s in S:
        if tmp != s:
            counter += 1
        tmp = s
    print(counter)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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 = list(str(input()))

if len(s) == 1:
  print(0)
  exit()
  
temp = s[0]
c = 0

for i in range(1, len(s)):
  if s[i] != temp:
    c += 1
    temp = s[i]
  else:
    continue

print(c)

Submission status: Accepted

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

s = list(input())[:-1]

reverse = 0
current = 'X'
for x in s:
    if current != x:
        reverse+=1
        current = x

reverse-=1

print(reverse)

Submission status: Accepted

Solution code:

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

print(border)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(input())
count = 0
tmp = S[0]

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

print(count)

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

Submission status: Accepted

Solution code:
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import bisect



def main():
    data = list(input())
    #
    # if data.count('W') == 0 or data.count('B') == 0:
    #     print(0)
    #     sys.exit()

    white, black = 0, 0

    pre = ''
    for i in range(len(data)):
        if pre == data[i]:
            continue
        pre = data[i]
        if data[i] == 'W':
            white += 1
        else:
            black += 1

    print(black+white - 1)



if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(num)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(S: str):
    def count(s):
        tmp = s[0]
        cnt = 0
        for c in s:
            if c != tmp:
                cnt += 1
                tmp = c
        return cnt
    #ret = min(count(S), count(str(reversed(list(S)))))
    ret = count(S)
    print(ret)
    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()
old="x"
ans=-1
for c in s:
    if old != c:
        ans+=1
    old=c
    
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

S = sys.stdin.readline().rstrip()
cnt = 0
p = None
for c in S:
    cnt += p != c
    p = c
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:
# ABC 47, C 1d reversi
S = input()
now = S[0]
k = 1
for s in S[1:]:
    if s == now:
        pass
    else:
        k += 1
        now = s
print(k-1)

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:
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:
# -*- coding:utf-8 -*-
"""考え方
・BBBBWWW
右にBを置けば良い

・WWBBWW
右にBを置く
右にWを置く

・WBWBWBWBBBBBBW
右にBWBWBWBWの順に置く
または、
左にBWBWBWBWの順に置く

どうやら、左と右でもかわらない様子
"""
def solve():
    S = input()

    ans = 0
    now = S[0]
    for i, moji in enumerate(list(S)):
        if now == moji:
            continue
        ans += 1
        now = moji
    print(ans)
    

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:

S = input()


ans = 0
now = ""

for s in S:

    if now != s:

        now = s
        ans += 1

print (ans-1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

Solution code:
S = input()

color = None
count = 0
for i in list(S):
  if i != color:
    count += 1 

  color = i

print(count-1)

Submission status: Accepted

Solution code:
def main():
    s = list(input())
    tmp = s[0]
    res= 0

    for i in s[1:]:
        if i != tmp:
            res += 1
            tmp = i
    print(res)

if __name__ == '__main__':
    main()

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 = str(input())
print(s.count("WB")+s.count("BW"))

Submission status: Accepted

Solution code:
S=input()

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

Submission status: Accepted

Solution code:
S=input()

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

print(ans)

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

Solution code:
S = input()
newS = ''
if len(S) == 1:print(0)
else:
    i = pre = 0
    while True:
        if i > len(S) - 1:
            newS = newS + S[pre]
            break
        else:
            if S[pre] != S[i]:
                newS = newS + S[pre]
                pre = i
            else:i += 1
    print(len(newS)-1)

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

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

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

Submission status: Accepted

Solution code:
S = input()

WBWB = []
phase = 'W'
count = 0
for i in range(len(S)):
    if S[i] == 'W' and phase == 'B':
        WBWB.append(count)
        phase = 'W'
        count = 0
    if S[i] == 'B' and phase == 'W':
        WBWB.append(count)
        phase = 'B'
        count = 0
    count += 1
WBWB.append(count)
temp = []
if WBWB[0] == 0:
    WBWB = WBWB[1:]

if len(WBWB) == 0:
    ans = 0
else:
    ans = len(WBWB) - 1

print(ans)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

pre_state = S[0]
cnt = 0
for i in range(1,len(S)):
  if not S[i] == pre_state:
    pre_state = S[i]
    cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
s = input()
if s.find("W") == -1 or s.find("B") == -1:
    print(0)
elif len(s) == 1:
    print(2)
else:
    res = 0
    c = s[0]
    for i in range(len(s) - 1):
        if c != s[1+i]:
            c = s[1+i]
            res += 1
    print(res)

Submission status: Accepted

Solution code:
s = input()
wb_counter = s.count("WB")
bw_counter = s.count("BW")
print(wb_counter + bw_counter)

Submission status: Accepted

Solution code:
b = input()
d = []
isWhite = False
cnt = 0
for i in range(len(b)-1):
  if b[i] != b[i+1]:
    d.append(cnt)
  else:
    cnt+=1

print(len(d))

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

flg = s[0]
cnt = 1

for i in s:
    if flg == i:
        pass
    else:
        flg = i
        cnt += 1

print(cnt-1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a=list(input())
a.append("A")
cnt=0
for i in range(len(a)-1):
    if a[i]!=a[i+1]:
        cnt+=1
print(cnt-1)

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(max(count,0))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

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

print(cost)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
a = input()
#1打つことで変わり目を1つ解消できる
cnt = 0
for i in range(1,len(a)):
    if a[i]!= a[i-1]:
        cnt+=1
print(cnt)

Submission status: Accepted

Solution code:
# 頭からみていって違う色がきたら先頭にその色を置くことでそこまでの色はすべて同じにできる
s = input()
count = 0
for si in range(1, len(s)):
    if s[si - 1] != s[si]:
        count += 1
print(count)

Submission status: Accepted

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

Submission status: Accepted

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


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

Submission status: Accepted

Solution code:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

S = str(input())

ans_w = 0
cnt = [0,0] # W,B
left = S[0]
if left == "B":
    cnt[1] += 1
else:
    cnt[0] += 1
for i in range(1,len(S)):
    if left == S[i]:
        pass
    else:
        left = S[i]
        if left == "B":
            cnt[1] += 1
        else:
            cnt[0] += 1

if cnt[0] == cnt[1]:
    ans = (cnt[0] - 1) * 2 + 1

else:
    ans = min(cnt)*2
print(ans)

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

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

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  s=S()
  a=s[0]

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

  return c

print(main())

Submission status: Accepted

Solution code:
S = input()
count = 0
temp = S[-1]
for s in S[-2::-1]:
    if s != temp:
        count += 1
    temp = s
print(0 if count == 0 else count)

Submission status: Accepted

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