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:
import sys
from functools import reduce
import copy
import math
from pprint import pprint
import collections
import bisect
import itertools


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    S = list(inputs[0])
    prev = None
    count = 0
    for c in S:
        if prev is not None and prev != c:
            count += 1
        prev = c
    return count


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)

Submission status: Accepted

Solution code:
import re
# 盤面の状態
s = input()

# Aマッチする数を数える
w = re.findall(r'[W]+', s)
# Bにマッチする数を数える
b= re.findall(r'[B]+', s)

# 全部Wなら入れ替える必要なし
if s.count("W") == len(s):
    print(0)
else:
    print(len(w)+len(b)-1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
a = [c for c in S]

border = 0

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

print(border)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = 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:
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))


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

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

Submission status: Accepted

Solution code:
S = [i for i in 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()
print(S.count("BW") + S.count("WB"))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
ans=0
for x,y in zip(s,s[1:]):
  if x!=y:ans+=1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    s=input()
    now=s[0]
    cnt=0
    for i in range(1,len(s)):
        if now!=s[i]:
            cnt+=1
            now=s[i]
    print(cnt)
if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
from sys import stdin

s = stdin.readline().rstrip()

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

print(point)

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:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
from itertools import groupby
def resolve():
    S=input()
    print(len(tuple(groupby(S)))-1)
resolve()

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

print(cnt)

Submission status: Accepted

Solution code:
s = input()
count = 0
while True :
    if s == "" :
        break
    elif s[-1] == "B":
        s = s.rstrip("B")
        count += 1
    elif s[-1] == "W" :
        s = s.rstrip("W")
        count += 1
print(count -1)

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin
 
ni = lambda:int(ns())
na = lambda:list(map(int,stdin.readline().split()))
ns = lambda:stdin.readline().rstrip()  # ignore trailing spaces

S = ns()
answer = 0
cur = S[0]

for s in S:
    if s != cur:
        answer += 1
        cur = s

print(answer)

Submission status: Accepted

Solution code:
def main():
    s = input()
    now = s[0]
    ans = 0
    for i in range(1,len(s)):
        if now==s[i]:
            pass
        else:
            now = s[i]
            ans += 1
    print(ans)
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def main():
    S = input()
    if S[0] == "B":
        K = "WB"
    else:
        K = "BW"
    cnt = S.count(K)

    if S[0] == S[-1]:
        print(2 * cnt)
    else:
        print(1 + 2 * cnt)


main()

Submission status: Accepted

Solution code:
def main():
    S = input()
    if S[0] == "B":
        K = "WB"
    else:
        K = "BW"

    cnt = 0
    for i in range(len(S)-1):
        if S[i:i+2] == K:
            cnt += 1

    if S[0] == S[-1]:
        print(2 * cnt)
    else:
        print(1 + 2 * cnt)


main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
a = s[0]
for i in range(1,len(s)):
  if s[i]!=s[i-1]: a+= s[i]
if a.count("W") ==0 or a.count("B")==0:
  print(0)
else:
  print(len(a)-1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = 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=input()
a=[s[0]]
p=s[0]
for x in s:
  if x!=p:
    a.append(x)
  p=x
print(len(a)-1)

Submission status: Accepted

Solution code:
S = str(input())

count = 0

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

print(count)

Submission status: Accepted

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

print(counter)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 2019-11-20 12:21:36(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# import re
# import heapq
# import array
# from scipy.misc import comb # (default: exact=False)
# import numpy as np 


def main():
    s = sys.stdin.readline().rstrip()

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

    print(count)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
l = input()
def runlength(S):
    ans = []
    for s in S:
        if len(ans) == 0 or ans[-1][0] != s:
            ans.append([s,1])
        else:
            ans[-1][1] += 1
    return ans
print(len(runlength(l))-1)

Submission status: Accepted

Solution code:
#import math.sqrt as sqrt
S = input()
#data = list(map(int,input().split()))
count = 0
for i in range(len(S)-1):
    if S[i]!=S[i+1]:
        count += 1


print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from operator import itemgetter

#入力
s=list(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:
a=list(str(input()))
count=0
for i in range(0,len(a)-1,1):
    if a[i]!=a[i+1]:
        count+=1
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#ABC047 C - 一次元リバーシ / 1D Reversi
S = input()
cur_s = ''
SS=[] 
for i,s in enumerate(S):
    if i==0:
        cur_s = s
        SS.append(s)
        continue
    if i==len(S):
        if cur_s == s:
            continue
        else:
            SS.append(s)
            continue

    if cur_s == s:
        continue
    else:
        SS.append(s)
        cur_s = s

n = len(SS)
m = n//2
if n==1:
    print(0)
    exit()

if n%2==1:
    print(m*2)
else:
    print(((n//2)*2)-1)

Submission status: Accepted

Solution code:
def solve():
    S = input()

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

if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(S: str):
    c = 0
    b = S[0]
    N = len(S)
    for i in range(1,N):
        if S[i] != S[i-1]:
            c += 1

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

T=S[0]
c=0

for s in S:
    if(T!=s):
        c+=1
        T=s
print(c)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

Solution code:
S = input()
ans = 0
prev = ""
for i, s in enumerate(S):
  if i == 0:
    prev = s
  else:
    if prev != s:
      ans += 1
    prev = s
print(ans)

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

Solution code:
def solve():
    s = input()

    if s.count("W") == 0 or s.count("W") == len(s):
        return 0

    counter = 0
    i = len(s) - 1
    while 0 < i:
        tail = s[i]
        # print("i, tail", i, tail)
        if tail == "W":
            # 右端に B を打つ
            # print("B")
            counter += 1
            # 直近の B を探す
            while 0 < i and not s[i] == "B":
                i -= 1
            # print("\t", i)
            # assert s[i] == "B"

            # 左端の B を探す
            if s[i - 1] == "B":
                while 0 < i and s[i - 1] == "B":
                    i -= 1
            # print("\t\t", i)

        else:
            # 右端に W を打つ
            # print("W")
            counter += 1
            # 直近の W を探す
            while 0 < i and not s[i] == "W":
                i -= 1
            # print("\t", i)
            # assert s[i] == "W"

            # 左端の W を探す
            if s[i - 1] == "W":
                while 0 < i and s[i - 1] == "W":
                    i -= 1
            # print("\t\t", i)

    # print("c", counter)

    return counter


if __name__ == '__main__':
    res = solve()
    print(res)

Submission status: Accepted

Solution code:
# python3 (3.4.3)
import sys
input = sys.stdin.readline

# main
S = input().rstrip()

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

print(ans)

Submission status: Accepted

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



import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC()

Submission status: Accepted

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

    print(count)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def main():
    S = input()
    if len(set(S)) == 1:
        print(0)
    else:
        s2 = ''
        prev = ''
        for si in S:
            if si == prev:
                pass
            else:
                s2 += si
            prev = si
        
        print(len(s2) - 1)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
S=input()

count=0
for ind,color in enumerate(S):
    if(ind==0):
        c=color
    else:
        if(c==color):
            continue
        else:
            count+=1
            c=color
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)


def main():
    s = input()
    compressed = ""
    for i in range(len(s)-1):
        if s[i] != s[i+1]:
            compressed += s[i]
    compressed += s[-1]

    print(len(compressed)-1)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    S = input()
    print(sum(1 for x, y in zip(S[:], S[1:]) if x != y))
    return


main()

Submission status: Accepted

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


main()

Submission status: Accepted

Solution code:
def main():
    S = input()
    ans = -1
    pre = ""
    for s in S:
        if pre != s:
            ans += 1
            pre = s
    print(ans)
    return


main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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:
#import math
#import copy
#import sys
#import bisect
#input = sys.stdin.readline
mod=10**9+7
def factorial(x): #階乗計算
    n=1
    for i in range(x):
        n=(n*(i+1))%mod
    return n

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
def lcm(a, b):
    return((a*b)//gcd(a,b))
def div(x): #約数配列
    div=[1]
    check=2
    while(x!=1 and check <= int(x**0.5)+2):
        if(x%check==0):
            div.append(check)
            while(x%check==0):
                x=x//check
        check+=1
    if x != 1:
      div.append(x)
    return div
def div2(x): #素因数分解配列
    div2=[]
    check=2
    while(x!=1 and check <= int(x**0.5)+2):
        while x%check==0:
            div2.append(check)
            x/=check
        check+=1
    if x != 1:
      div2.append(x)
    return div2

def main():
    # x,y = map(int,input().split())           x=1,y=2
    # a = input().split()                      a=['1','2','3',...,'n']
    # a = list(map(int,input().split()))       a=[1,2,3,4,5,...,n]
    # li = input().split('T')	              FFFTFTTFF => li=['FFF', 'F', '', 'FF']
    # 複数行の「1 2 3 4」型の入力を一配列に
    # x = sorted([list(map(int, input().split())) for _ in range(n)])
    # ソート x.sort(key=lambda y:y[1])
    # [chr(i) for i in range(97, 97+26)] 英語小文字リスト
    # [chr(i) for i in range(65, 65+26)] 英語大文字リスト
    s=list(input())
    ans=0
    n=len(s)
    for i in range(n-1):
        if s[i]!=s[i+1]:
            ans+=1
    print(ans)
main()

Submission status: Accepted

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

def solve(S: str):
    a = itertools.groupby(S)
    print(len(list((a)))-1)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
"ABC 047 C - 一次元リバーシ / 1D Reversi "

if __name__ == "__main__":
    S = input()

    ans = 0
    tmp = S[0]
    for s in S:
        if s is not tmp:
            ans += 1
            tmp = s

    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
cnt=0
col=s[0]
for i in s:
    if i==col:continue
    else:
        col=i
        cnt +=1
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
n=len(s)
grps=0 
i=0
c=0 
while i<n: 
    curr=s[i]
    c+=1 
    while i<n and curr==s[i]:
        i+=1 
print(c-1)

Submission status: Accepted

Solution code:
s=input()
from itertools import groupby
g=groupby(s)
a=[]
for i,j in g:
  a.append(i)
print(len(a)-1)

Submission status: Accepted

Solution code:
# C - 一次元リバーシ / 1D Reversi

S = input()

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

Submission status: Accepted

Solution code:
S = list(input())
size = len(S)
b = [] 
cnt = 0 
now = S[0]
for i in range(size):
  if S[i] == now :
    cnt += 1
  else:
    b.append(cnt)
    now = S[i]
    cnt = 0
b.append(cnt)
print("{}".format(len(b)-1))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=input()

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

Submission status: Accepted

Solution code:
S = input().strip()
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())
if len(list(set(s))) == 1:
    print(0)
else:
    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())
l = len(S)
ans = 0
for i in range(l):
    if S[l - 1 - i] != S[-1]:
        S[-1] = S[l - 1 - i]
        ans += 1
        i += 1
print(ans)

Submission status: Accepted

Solution code:
s=str(input())

tmp = s[0]
cnt = 0

for i in s:
    if tmp != i:
        cnt += 1
        tmp = i

print(cnt)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
S=list(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:
st = input()
total = 0
for i in range(1, len(st)):
    if st[i] != st[i - 1]:
        total += 1
print(total)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque

if __name__ == "__main__":
    s = deque(input())
    #  find amount of sequence minus 1
    sequenceCount = 0
    stone = s[0]
    for letter in s:
        if letter != stone:
            sequenceCount += 1
            stone = letter
    print(sequenceCount)

Submission status: Accepted

Solution code:
s = input()

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

print(c)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
S = list(input())

b = []
w = []
num = 1

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

if S[0] == S[1]:
    Flag = True
else:
    Flag = False

for i in range(1, len(S)):
    if S[i-1] == S[i]:
        Flag = True
        num += 1
    else:
        Flag = False
        if S[i-1] == 'B':
            b.append(num)
        elif S[i-1] == 'W':
            w.append(num)
        num = 1

if S[-1] == 'B':
    b.append(num)
else:
    w.append(num)

if num == len(S):
    ans = 0
else:
    n_b = len(b)
    n_w = len(w)
    n = min(n_b, n_w)

    if (n_b + n_w) % 2 == 0:
        ans = 2 * n - 1
    else:
        ans = 2 * n

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

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

print(len(s) - 1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
ans = 0
bw = S[0]

for i in S:
    if bw != i:
        ans += 1
        bw = i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

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

print(ans)

Submission status: Accepted

Solution code:
s = input().rstrip()
prev = s[0]
res = 0
for c in s[1:]:
    if c != prev:
        res += 1
        prev = c
print(res)

Submission status: Accepted

Solution code:
s = input()
ans = 0
bw = s[0]
for i in s:
    if bw == "B" and i == "W":
        ans += 1
        bw = "W"
    elif bw == "W" and i == "B":
        ans += 1
        bw = "B"
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(input())
count_left = 0
last = s[0]
for one_color in s:
  if last != one_color:
    count_left += 1
    last = one_color

count_right = 0
last = s[-1]
for one_color in s[::-1]:
  if last != one_color:
    count_right += 1
    last = one_color

print(min(count_left, count_right))

Submission status: Accepted

Solution code:
s = input()
w = ""
cnt1 = 0
for x in s[1:]:
	if x != w:
		cnt1 += 1
		w = x

cnt2 = 0
for x in s[-2::-1]:
	if x != w:
		cnt2 += 1
		w = x

print(min(cnt1, cnt2))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
S = (stdin.readline().rstrip())
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
now = s[0]
for si in s[1:]:
    if now == si:
        continue
    ans += 1
    now = si
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 = list(input())
s = 0
for i in range(len(S)-1):
    if S[i] != S[i+1]:
        s += 1
print(s)

Submission status: Accepted

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

s = input()

ans = s.count("WB") + s.count("BW")
print(ans)

Submission status: Accepted

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

from itertools import groupby

s = input()

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

Submission status: Accepted

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

s = input()

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

print(cnt)

Submission status: Accepted

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

def main():
    S = input()
    count = 0
    for i in range(len(S) - 1):
        if S[i] == S[i+1]:
            pass
        else:
            count += 1
    print(count)
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)