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

ans = 0
B = S[0] == "B"

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

Submission status: Accepted

Solution code:
s = input()
n = len(s)
ans = -1
pre = ""

for i in s:
    if i != pre:
        ans += 1
    pre = i

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
s = input()
ans = 0

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

Submission status: Accepted

Solution code:
S=input()

now=S[0]

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Thu Jun 11 17:09:47 2020

@author: sd18016
"""   

import sys
from itertools import groupby


S = list(input())

ans = len(list(groupby(S)))-1
print(ans)
    
    


"""
for i in range(N):
    if list_x[i][2] == 1:
        de = list_x[i][0]
        S -= de*H
        W -= de
    elif list_x[i][2] == 2:
        de = W - list_x[i][0]
        S -= de*H
        W -= de
    elif list_x[i][2] == 3:
        de = list_x[i][1]
        S -= de*W
        H -= de
    else:
        de = H - list_x[i][1]
        S -= de*W
        H -= de

print(S)
"""

Submission status: Accepted

Solution code:
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    s=readline().strip()

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

    print(cnt-1)

if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
s = input()

c = 0
tmp = s[0]
for i in s:
    if i != tmp:
        c += 1
    tmp = i

print(c)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
if 'W' not in S:
    print(0)
elif 'B' not in S:
    print(0)
else:
    if S[0] == 'B':
        count = S.count('BW')
        if S[-1] == 'B':
            print(count*2)
        else:
            print(count*2 - 1)
    else:
        count = S.count('WB')
        if S[-1] == 'W':
            print(count*2)
        else:
            print(count*2 - 1)

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

Solution code:
S=list(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:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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


if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
# 20200610_yorukatsu_f.py
S = input()
cnt = 0
for i,c in enumerate(S):
    if i>0:
        if c!=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:
import numpy as np
import sys
def sinput(): return sys.stdin.readline()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(): return list(imap())
def farr(): return list(fmap())
def sarr(): return sinput().split()

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
a = input()

p = a.count("WB")
q = a.count("BW")

print(p + q)

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

Submission status: Accepted

Solution code:
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]
# @lru_cache(None)






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 sys

input = sys.stdin.readline


def main():
    S = input().rstrip()
    N = len(S)

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

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
line = list(input())
temp = line[0]
cnt = 0
for c in line[1:]:
	if temp != c:
		cnt += 1
		temp = c

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:
import sys

s = input()

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

print(ans)

Submission status: Accepted

Solution code:
from itertools import groupby

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

Submission status: Accepted

Solution code:
from collections import deque

s = deque(input())
cnt = 0
p = s.pop()
for _ in range(len(s)):
    n = s.pop()
    if n != p:
        cnt += 1
    p = n
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    S = input()
    p = S[0]
    c = 0
    for s in S[1:]:
        if s != p:
            p = s
            c += 1
    print(c)
    
if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def v():
    S=sys.stdin.readline().strip()
    c,res=S[0],0
    for s in S:
        if c!=s:c,res=s,res+1
    print(res)
if __name__=='__main__':v()

Submission status: Accepted

Solution code:
from itertools import groupby

s =list(input())
a = []

for key, value in groupby(s):
    a.append(key)


print(len(a)-1)

Submission status: Accepted

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

s = input()
print(answer(s))

Submission status: Accepted

Solution code:
def main():
    S = input()
    ans = 0
    before_c = S[0]
    for c in S:
        if c != before_c:
            ans += 1
            before_c = c
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = input()
if S.count('B') == 0 or S.count('W') == 0:
    print(0)
    exit()
for _ in range(20):
    S = S.replace('BB','B').replace('WW','W')
print(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()

# 圧縮した文字列 t に対して len(t) - 1 が答え

from itertools import groupby

groups = []
uniquekeys = []
for k, g in groupby(s):
    groups.append(list(g))
    uniquekeys.append(k)

# print(groups)
# print(uniquekeys)

print(len(uniquekeys) - 1)

Submission status: Accepted

Solution code:
def solve():
    S = input()
    
    d = {'B': 0, 'W': 0}
    ps = S[0]
    d[ps] += 1
    for si in S:
        if si != ps:
            d[si] += 1
        ps = si   
    return sum(d.values())-1

print(solve())

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

s=SI()
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()

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

Submission status: Accepted

Solution code:
s = list(input())

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

print(ans)

Submission status: Accepted

Solution code:
s = list(input())

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

ans = 0
tmp = s[0]
state = False
for i in range(1,len(s)):
    if tmp == "B" and s[i] == "W":
        state = True
    elif tmp == "B" and s[i] == "B":
        if state:
            ans += 2
            state = False
            tmp = "B"
    if tmp == "W" and s[i] == "B":
        state = True
    elif tmp == "W" and s[i] == "W":
        if state:
            ans += 2
            state = False
            tmp = "W"

if state:
    ans += 1
print(ans)

Submission status: Accepted

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

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

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

print(res)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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:
def myAnswer(S:str) -> int:
   ans = 0
   pre = S[0]
   for s in S[1:]:
      if (pre != s):
         pre = s
         ans += 1
   return ans

def modelAnswer():
   return
def main():
   S = input()

   print(myAnswer(S))
if __name__ == '__main__':
   main()

Submission status: Accepted

Solution code:
s = input()

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

print(len(ans))

Submission status: Accepted

Solution code:
S = input()
result = -1
piyo = ""
for s in S:
    if piyo != s:
        piyo = s
        result += 1
print(result)

Submission status: Accepted

Solution code:
S = input()

prev = S[0]
switch_count = 0
for bw in S[1:]:
    if bw != prev:
        switch_count += 1
    prev = bw

print(switch_count)

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()
now = s[0]
ans = 0

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

Submission status: Accepted

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

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]

if len(S) == 1:
    print(0)
    exit(0)
elif len(S) == 2:
    print(1)
    exit(0)

print(len(s)-1)

Submission status: Accepted

Solution code:
s = input()
num = len(s)
'''
WBWBWBWBWB
9ko
'''
temp = s[0]
ans = 0
for i in range(1, num):
    if (temp == s[i]):
        pass
    else:
        ans += 1
        temp = s[i]

print(ans)

Submission status: Accepted

Solution code:
def main():
    from itertools import tee

    S = input()
    it1, it2 = tee(iter(S), 2)
    next(it2)

    ans = 0
    for c1, c2 in zip(it1, it2):
        if c1 != c2: ans += 1
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

color = S[0]

cnt = 0

for c in S:
    if c != color:
        cnt += 1
        color = c

print(cnt)

Submission status: Accepted

Solution code:
s = input()
wb = s[0]
c = 0
for i in range(1, len(s)):
    if s[i] == wb:
        continue
    else:
        c += 1
        wb = s[i]

print(c)

Submission status: Accepted

Solution code:
from sys import stdin
input = stdin.readline
import copy as cp
from collections import deque

def VI(N, init=0):
  return [init for _ in range(N)]
def VVI(N, M, init=0):
  return [[init for _ in range(M)] for _ in range(N)]

def VD(N, init=0.0):
  return [init for _ in range(N)]
def VVD(N, M, init=0.0):
  return [[init for _ in range(M)] for _ in range(N)]

def Decimal(x):
  print("{0:.10f}".format(x))

class Pair:
  def __init__(self, x=0, y=0):
    self.first = x
    self.second = y

  def __repr__(self):
    return '{0} {1}'.format(self.first, self.second)

  def __lt__(self, pi):
    return self.first < pi.second

def POW(x, n):
  ret = 1
  while n:
    if n&1:
      ret *= x
    x *= x
    n >>= 1
  return ret

def Block(s):
  num = 1
  v1 = []
  v2 = []
  for i in range(len(s)):
    c = s[i]
    if i == 0:
      v1.append(c)
    elif c == s[i-1]:
      num += 1
    else:
      v2.append(num)
      v1.append(c)
      num = 1

    if i == len(s)-1:
      v2.append(num)
  return v1, v2

S = input().rstrip()
chs, num = Block(S)

print(len(chs)-1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(input())

cnt = 0
check = ""

for i in range(len(s)):
    if check == "":
        check = s[i]
        continue

    if check == s[i]:
        continue
    else:
        check = s[i]
        cnt += 1


print(cnt)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

def solve():
    input = sys.stdin.readline
    S = input().strip("\n")
    turn = 0
    current = S[0]
    for i in range(1, len(S)):
        if S[i] != current:
            turn += 1
            current = S[i]
    print(turn)

    return 0

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
S = input().strip()
cur = S[0]
cnt = 0
for i in range(1,len(S)):
    if S[i]==cur:continue
    else:
        cnt += 1
        cur = S[i]
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 = str(input())
n = len(s)
cur = s[0]
cnt = 0
L = []
for i in range(n):
    if s[i] != cur:
        L.append(cnt)
        cur = s[i]
        cnt = 1
    else:
        cnt += 1
else:
    L.append(cnt)
#print(L)
print(len(L)-1)

Submission status: Accepted

Solution code:
s = input()
S = []
b = ""
for i in s:
  if b == "":
    S.append(i)
    b = i
  elif b == i: continue
  else:
    S.append(i)
    b = i
print(len(S)-1)

Submission status: Accepted

Solution code:
S = input()

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

print(cnt)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from collections import *

S = input()[:-1]
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 = str(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:
from itertools import groupby
N=input()
S=list(groupby(N))
print(len(S)-1)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
import sys
s = input()

if all([x == s[0] for x in s]):
    print(0)
    sys.exit()

bw = s.count("BW")
wb = s.count("WB")

print(bw + wb)

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

s_ = S[0]

ans = 0
for s in S[1:]:
    if s != s_:
        ans += 1
    s_ = s

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####GCD#####
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############
S = S()

prev = 0
count = 0
for s in S:
  if s != prev:
    count+=1
  prev = s
P(count-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=list(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

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

main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()

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

Submission status: Accepted

Solution code:
import sys
from collections import Counter
from collections import deque
import math
import bisect
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

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 = 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 = list(input())
compress = [s[0]]

ans = 0
for c in s:
    if c == compress[-1]:
        continue
    ans += 1
    compress.append(c)

print(ans)

Submission status: Accepted

Solution code:
S=input()
#変わり目数える
pre=S[0]
ans=0
for i in range(1,len(S)):
    s=S[i]
    if s!=pre:
        ans+=1
    pre=s
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input().strip()
cnt = 0
cur = S[0]
cnt += 1
for i in range(1,len(S)):
    if S[i]==cur:continue
    else:
        cnt += 1
        cur = S[i]
print(cnt-1)

Submission status: Accepted

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

Submission status: Accepted

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

def main():
    S = readline().strip()
    N = len(S)

    seq = [1]
    for i in range(N-1):
        if S[i+1] == S[i]:
            seq[-1] += 1
        else:
            seq.append(1)
    
    ans = len(seq) - 1
    print(ans)



if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve():
    S = input()
    ans = S.count('BW')+S.count('WB')
    return ans
print(solve())

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    s = input()
    n = len(s)

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


if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
import sys
# input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

dp = [0]*n
dp[0]=1
for i in range(1,n):
    if s[i-1]==s[i]:
        continue
    dp[i]=1
print(sum(dp)-1)

Submission status: Accepted

Solution code:
s=input()
n=len(s)
ans=s.count("WB")
anss=s.count("BW")
print(ans+anss)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    S = readline().decode('utf-8').strip()
    change = 0
    L = len(S)
    for i in range(1,L):
        if S[i-1]!=S[i]:
            change += 1
    print(change)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**6)
INF = float('inf')
MOD = 10 ** 9 + 7
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rf(): return float(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]
def rf_(): return [float(_) for _ in rs().split()]
def divisors(n, sortedresult=True):
    div = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            div.append(i)
            if i != n // i:
                div.append(n//i)
    if sortedresult:
        div.sort()
    return div
# endregion
S = rs()
f = ''
ans = -1
for i in S:
    if f != i:
        ans += 1
    f = i
print(ans)