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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
l = list(s[0])
for i in s:
  if i!=l[-1]:
    l.append(i)
print(len(l)-1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from itertools import groupby


def main():
    S = input()

    result = 0
    for i in groupby(S):
        result += 1

    print(result - 1)


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

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

Submission status: Accepted

Solution code:
s = input()

now = ''
counter = 0

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

print(counter)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import io

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

Submission status: Accepted

Solution code:
S = input()

# 1以上の同じ色の石の列は1つに集約できる
cnt = 1
prev = S[0]
for s in S[1:]:
    if prev != s:
        cnt += 1
        prev = s

print(cnt - 1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#coding: utf-8

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()
N = len(S)
slist = []
solvelist = []
for i in range(N):
    slist.append(S[i])

solvelist.append(S[0])
for i in range(N-1):
    if slist[i] == slist[i + 1]:
        pass
    else:
        solvelist.append(S[i+1])

ans = len(solvelist) - 1

print(ans)

Submission status: Accepted

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


ans = cnt
cnt = 0
now = s[-1]
for i in range(n-2,-1,-1):
    if s[i] != now:
        cnt+=1
        now = s[i]
ans = min(cnt,ans)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

S = list(input())
ls = len(S)

if ls == 1:
    print(0)
    sys.exit()
elif len(set(S)) == 1:
    print(0)
    sys.exit()

tg = S[0]
n = 0
for i in range(ls):
    if i == 0:
        continue
    else:
        if S[i] != tg:
            n += 1
            tg = S[i]
print(n)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
S = input()
S = [1 if s == 'W' else -1 for s in S]

# BBBWW
# WBWBWBWBWBBWWW 1個以上のつながりはぐるーぷとしてかんがえてOK
# １試行ごとにグループを一つ消せる
# 最後のグループは消さなくていいので何グループあるか考えて - 1したものが答え

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

Submission status: Accepted

Solution code:
from collections import Counter
s = list(input()) # 入力が1つ
# map(int, input().split()) # 入力が複数
# [int(i) for i in input().split()] # 配列で数字

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

Submission status: Accepted

Solution code:
def solve(s):
    prev = s[0]
    count = 0
    for i in s[1:]:
        if prev != i:
            count += 1
        prev = i
    return count

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

Submission status: Accepted

Solution code:
s = input()

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

print(len(S) - 1)

Submission status: Accepted

Solution code:
def main():
    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
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(1000000)

S = list(input())
L = len(S)
b = S.count("B")
w = S.count("W")

def f(i, result):
  if S[i] == S[i-1]:
    if i == 1:
      print(result)
      exit()
    else:
      f(i-1, result)
  else:
    if i == 1:
      result += 1
      print(result)
      exit()
    else:
      result += 1
      f(i-1, result)
      
if L == 1:
  result = 0
  print(result)
  exit()
elif b == L or w == L:
  result = 0
  print(result)
  exit()
else:
  f(L-1, 0)

Submission status: Accepted

Solution code:
import sys

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

def main():
    prev = '$'
    cnt = -1
    for c in s:
        cnt += c != prev
        prev = c
    print(cnt)

if __name__ ==  '__main__':
    main()

Submission status: Accepted

Solution code:
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

""" n! mod m 階乗
mod = 1e9 + 7
N = 10000000
fac = [0] * N
def ini():
  fac[0] = 1 % mod
  for i in range(1,N):
    fac[i] = fac[i-1] * i % mod"""

"""mod = 1e9+7
N = 10000000
pw = [0] * N
def ini(c):
  pw[0] = 1 % mod
  for i in range(1,N):
    pw[i] = pw[i-1] * c % mod"""

"""
def YEILD():
  yield 'one'
  yield 'two'
  yield 'three'
generator = YEILD()
print(next(generator))
print(next(generator))
print(next(generator))
"""
"""def gcd_(a,b):
  if b == 0:#結局はc,0の最大公約数はcなのに
    return a
  return gcd_(a,a % b) # a = p * b + q"""
"""def extgcd(a,b,x,y):
  d = a
  if b!=0:
    d = extgcd(b,a%b,y,x)
    y -= (a//b) * x
    print(x,y)
  else:
    x = 1
    y = 0
  return d"""


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

def main():
  s = input()
  ans = 0
  slen = len(s)
  COMP = s[slen-1]
  for i in range(slen-2, -1,-1):
    if COMP != s[i]:
      COMP = s[i]
      ans += 1
  print(ans)
if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
s=list(input())

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

Submission status: Accepted

Solution code:
def resolve():
    '''
    code here
    '''
    line = input()

    cnt = 1
    prev = line[0]

    if len(line) == 1:
        res = 0
    else:
        for item in line[1:]:
            if item == prev:
                pass
            else:
                cnt += 1
            prev = item
        res = cnt -1
    print(res)

if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
s = input()

prev = None
cnt = 0
for elem in s:
  if prev is None:
    prev = elem
  elif prev == elem:
    pass
  else:
    cnt += 1
    prev = elem
print(cnt)

Submission status: Accepted

Solution code:
s=input()

s = list(s)

count = 0

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

Submission status: Accepted

Solution code:
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:
from collections import deque
s = deque(input())
ans = 0
a = s.pop()
while len(s):
    b = s.pop()
    if a != b:
        ans += 1
        a = b
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def resolve():

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

resolve()

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
S = input()

s0 = ""
ans = 0
for s in S:
    if s0 != s:
        ans += 1
        s0 = s
print(ans - 1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

w_s = s[0]
RC = 0
for idx1 in range(1, len(s)):
    if s[idx1] != w_s:
        RC += 1
        w_s = s[idx1]

print(RC)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

S = input()
if len(set(S)) == 1:
    print(0)
    sys.exit()

tmp = ""
for i in range(1, len(S)):
    if S[i - 1] == S[i]:
        continue
    else:
        tmp += S[i - 1]

tmp += S[-1]
# print(tmp)
print(len(tmp) - 1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

#count blocks

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

Submission status: Accepted

Solution code:
S = input()

prev = "a"
cnt = 0
for s in S:
    if prev != s:
        cnt += 1
    prev = s
print(cnt-1)

Submission status: Accepted

Solution code:
S = input()

length = len(S)
ans = 0

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

print(ans)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input();print(sum(c!=d for c,d in zip(s,s[1:])))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

a = s.count('BW')
b = s.count('WB')

print(a + b)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

n = len(s)
ans = 0
s0 = s[0]
lastI = 0

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

for i in range(1, n-1):
    # print(s0)
    # print(s[i])
    # print(s[i+1])
    # print("----------")
    if s[i] != s0 and s[i+1] == s0:
        ans += 2
        lastI = i+1

if lastI != n-1 and s0 != s[-1]:
    ans += 1

print(ans)

Submission status: Accepted

Solution code:
s = input()

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

print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

s = []
before = S[0]
for i in range(len(S)):
    if S[i] != before:
        s.append(before)
        before = S[i]
    
    if i == len(S)-1:
        s.append(S[i])

print(len(s)-1)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from itertools import groupby

S = input().rstrip("\r\n")
g = groupby(S)
print(len(list(g))-1)

Submission status: Accepted

Solution code:
s=input()
l=[]
for i in s:
    if len(l)==0:
        l.append(i)
    else:
        if l[-1]==i:
            continue
        else:
            l.append(i)
print(len(l)-1)

Submission status: Accepted

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

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
tmp = ''
for w in s:
  if len(tmp)==0:
    tmp = w
    continue
  if tmp != w:
    ans+=1
    tmp = w

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# coding: utf-8
S = input()
N = len(S)
c = S[0]
cnt = 0 
for i in range(1,N):
    if S[i] != c:
        cnt += 1
        c = S[i]

print(cnt)

Submission status: Accepted

Solution code:
# coding: utf-8
S = input()
N = len(S)

def reversi(S):
    c = S[0]
    Flg = True
    cnt = 0
    for i in range(1,N):
        if Flg:
            if S[i] != c:
                #cnt += 1
                Flg = False
        else:
            if S[i] == c:
                cnt += 1
                Flg = True
    #print(cnt)
    if Flg:
        return cnt * 2
    else:
        return cnt * 2 + 1
print(reversi(S))

Submission status: Accepted

Solution code:
from itertools import groupby
S = list(input())

s = groupby(S)
ans = []
for key, group in s:
    ans.append(key)
print(len(ans)-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()
ans = 0
for s1, s2 in zip(s, s[1:]):
  if s1 != s2:
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
s=str(input())
cnt=0
l=len(s)
for i in range(l):
  if i==0:
    prev=s[i]
  else:
    nex=s[i]
    if nex!=prev:
      cnt+=1
    prev=nex
print(cnt)

Submission status: Accepted

Solution code:
s = input()

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

print(x)

Submission status: Accepted

Solution code:
s = input()

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

print(len(x) - 1)

Submission status: Accepted

Solution code:
S = [s for s in input()]
x = S.pop(0)
counter = 0 

while S:
  y = S.pop(0)
  if x!=y:
    counter += 1
    x = y

print(counter)

Submission status: Accepted

Solution code:
s=input()
for i in range(10**2):
  s=s.replace('WW','W').replace('BB','B')
print(len(s)-1)

Submission status: Accepted

Solution code:
s = input()

flag = s[0]
cnt = 0
for c in s:
    if flag == c:
        continue
    else:
        cnt+=1
        flag = c

print(cnt)

Submission status: Accepted

Solution code:
S = input()

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

print(ans)

Submission status: Accepted

Solution code:
import sys
#input = sys.stdin.buffer.readline
 
def main():
    s = input()
    l = len(s)
    
    count = 0
    for i in range(l-1):
        if s[i] != s[i+1]:
            count += 1
            
    print(count)
    
if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

i = 1

ans = 0

while i < n:
    if S[i - 1] != S[i]:
        ans += 1
    i += 1
print(ans)

Submission status: Accepted

Solution code:
S = input()
New_S = []
for i in range(1,len(S)):
    if S[i-1] != S[i]:
        New_S.append(S[i-1])
New_S.append(S[-1])
print(len(New_S)-1)

Submission status: Accepted

Solution code:


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

def main():
    mod=10**9+7
    S=input()
    N=len(S)
    a=S[0]
    ans=0
    for i in range(N):
        if S[i]!=a:
            ans+=1
            a=S[i]
            
    print(ans)

main()

Submission status: Accepted

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

S = input().strip()
#-----

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, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

s = input()
r = 0
# while r < N:
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()

ic = s[0]
ans = 0
for c in s:
    if c != ic:
        ans += 1
        ic = c

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

ban = []
prev = None
for s in S:
    if s == prev:
        continue
    else:
        ban.append(s)
        prev = s

print(len(ban) - 1)

Submission status: Accepted

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

Submission status: Accepted

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

s = readline().rstrip().decode('utf-8')

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

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


print(res)

Submission status: Accepted

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

for i in range(len(s)-1):
    if s[i] == 'B' and s[i+1] == 'W':
        ans += 1
    elif s[i] == 'W' and s[i+1] == 'B':
        ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
ans = 0
is_started = False
is_w = False
for s in S:
    if not is_started:
        is_w = True if s == 'W' else False
        is_started = True
    else:
        if s == 'W':
            if not is_w:
                ans += 1
            is_w = True
        else:
            if is_w:
                ans += 1
            is_w = False
print(ans)

Submission status: Accepted

Solution code:
s = input()
sw = 0
bef = s[0]

for i in s:
    if (bef != i):
        bef = i
        sw+=1
print(sw)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = str(input())

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

Submission status: Accepted

Solution code:
S = input()
islands = 1
for ix, s in enumerate(S):
    if ix == 0:
        tmp = s
    else:
        if s != tmp:
            islands += 1
            tmp = s
        else:
            pass

print(islands - 1)

Submission status: Accepted

Solution code:
#047_C
from itertools import groupby
s=input()
g=groupby(s)
print(len(list(g))-1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def runLength(str):
    """文字列strをランレングス圧縮して返す関数
    ex: "0000111101" => [(0,4), (1,4), (0,1), (1,1)]
    """
    res = []
    data, count = str[0], 1
    for i in range(1, len(str)):
        if str[i] == data:
            count += 1
        else:
            res.append((data, count))
            data, count = str[i], 1
    res.append((data, count))
    return res


S = input()
print(len(runLength(S)) - 1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

if S[0] == 'W':
    count = 0
    f = 0
    for i in range(len(S)):
        if S[i] == 'W' and f == 1:
            f = 0
            count += 1
        elif S[i] == 'B' and f == 0:
            f = 1
            count += 1
else:
    f = 0
    count = 0
    for i in range(len(S)):
        if S[i] == 'B' and f == 1:
            f = 0
            count += 1
        elif S[i] == 'W' and f == 0:
            f = 1
            count += 1

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#ABC047

s = input()

l = [0 if s[i] == s[i+1] else 1 for i in range(len(s)-1)]
print(sum(l))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(input())
prev = s[0]
section = 0
for i in s[1:]:
    if i != prev:
        section += 1
    prev = i
print(section)

Submission status: Accepted

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

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

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

def run_length_compress(string):
    """文字列をランレングス圧縮する
    例) string = "aabccaaabb" -> [(2, a), (1, b), (2, c), (3, a), (2, b)]
    """
    string = string + "@" # string中に絶対に現れない文字を番兵とする
    n = len(string)

    begin = 0
    end = 1
    cnt = 1
    ans = []
    while True:
        if end >= n:
            break
        if string[begin] == string[end]:
            end += 1
            cnt += 1
        else:
            ans.append((cnt, string[begin]))
            begin = end
            end = begin + 1
            cnt = 1

    return ans
  
print(len(run_length_compress(s)) - 1)

Submission status: Accepted

Solution code:
from itertools import groupby as gb

s = list(input())
g = gb(s)

print(len(list(g)) - 1)

Submission status: Accepted

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

for i in S[1:]:
    if check != i:
        count+=1
        check = i
        
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque
import sys
input = sys.stdin.readline
import bisect as bi

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


main()

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:
# coding: utf-8
# Your code here!
# coding: utf-8
from fractions import gcd 
from functools import reduce
import sys
sys.setrecursionlimit(200000000)
from inspect import currentframe


# my functions here!
#標準エラー出力
def printargs2err(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' : '+repr(arg) for arg in args),file=sys.stderr)
def debug(*args):
    print(*args,file=sys.stderr)

def printglobals():
    for (symbol, value) in globals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
def printlocals():
    for (symbol, value) in locals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
#入力（後でいじる）
def pin(type=int):
    return map(type,input().split())
     
#input

                
def resolve():
    s=input()
    ans=0
    for char in range(1,len(s)):
        ans+=s[char]!=s[char-1]
    print(ans)
        #print([["NA","YYMM"],["MMYY","AMBIGUOUS"]][cMMYY][cYYMM])
#if __name__=="__main__":resolve()

"""
#printデバッグ消した？
#前の問題の結果見てないのに次の問題に行くの？
"""
"""
お前カッコ閉じるの忘れてるだろ
"""
import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """BBBWW"""
        output = """1"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """WWWWWW"""
        output = """0"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """WBWBWBWBWB"""
        output = """9"""
        self.assertIO(input, output)

if __name__=="__main__":resolve()

Submission status: Accepted

Solution code:
S=input()
count=0
words=list(S)
n=len(words)-1
for a in range(n):
    if words[a]==words[a+1]:
        pass
    else:
        count+=1
print(count)

Submission status: Accepted

Solution code:
S = str(input())

counting = 0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
prev = ans = -1
for c in s:
    if prev != c:
        prev = c
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
S = input()

last = ""
ls = []
for s in S:
    if s != last:
        last = s
        ls.append(s)
    else:
        ls[-1] += s

print(len(ls)-1)

Submission status: Accepted

Solution code:
s = list(input())
ans = 0
prestr = s[0]
for id in range(len(s) - 1):
    if prestr == s[id + 1]: continue
    else: 
        ans += 1
        prestr = s[id + 1]
print(ans)