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

Submission status: Accepted

Solution code:
l = list(input())
now = l[0]
count = 0
for i in range(1, len(l)):
  if not l[i] == now:
    count += 1
    now = l[i]

print(count)

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(str(input()))
t = s[-1]
s.append(t)

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

Submission status: Accepted

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

    reversi = S
    while 1:
        before = reversi
        reversi = reversi.replace('BB', 'B')
        reversi = reversi.replace('WW', 'W')
        if reversi == before:
            break
    print(len(reversi) - 1)

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
l = len(s)
ans = 0
for i in range(1, l):
    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:
x=0
n=0
f='X'
for j in list(input().strip()):
  if n!=0 and f != j:
    x += 1  
  f = j
  n += 1
print(x)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l = list(input())
now = l[0]
count = 0

for i in range(1, len(l)):
  if not now == l[i]:
    count += 1
    now = l[i]

print(count)

Submission status: Accepted

Solution code:
def solve():
    S = input()
    ans = 0
    for i, stone in enumerate(list(S)):
        if i >= len(S) - 1:
            break
        if not stone == S[i + 1]:
            ans += 1
    print(ans)

solve()

Submission status: Accepted

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

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

print(cnt)

Submission status: Accepted

Solution code:
str = list(input())
out = 0
pro = str[0]
for i in range(len(str)):
    if pro != str[i]:
        out += 1
    pro =str[i]

print(out)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


if __name__ == '__main__':
    s = input()
    print(reversi(s))

Submission status: Accepted

Solution code:
def reversi(stones):
    s = list(stones)
    count = 0
    previous = s[-1]
    while s:
        current = s.pop()
        if current != previous:
            count += 1
            previous = current
    return count


if __name__ == '__main__':
    s = input()
    print(reversi(s))

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())
tmp_s = s.pop(0)

count = 0
for i in s:
    if tmp_s != i:
        count += 1
        tmp_s = i
print(count)

Submission status: Accepted

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

print(cnt - 1)

Submission status: Accepted

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

Submission status: Accepted

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

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
kukan = 0

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

print(kukan)

Submission status: Accepted

Solution code:
S = input()
WB = []
x = S[0]
wb = ""

for s in S:
    if s == x:
        wb += s
    else:
        WB.append(wb)
        wb = s
        x = s
WB.append(wb)
print(len(WB) - 1)

Submission status: Accepted

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

    print(cnt)



solve()

Submission status: Accepted

Solution code:
S=raw_input()
cnt=0
c=""
for ind,i in enumerate(S):
	if ind==0:
		c=i
	else:
		if c!=i:
			cnt+=1
			c=i

print cnt

Submission status: Accepted

Solution code:
S = input()
stone = {"B": 1, "W": 0}
p = stone[S[0]]
cnt = 1
for i in range(1, len(S)):
    if p != stone[S[i]]:
        cnt += 1
        p = stone[S[i]]
print(cnt-1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
pattern = raw_input()

first = pattern[0]
search = 'W' if first == 'B' else 'B'

moves = 0
spot = pattern.find(search)
while spot != -1:
    search = 'W' if search == 'B' else 'B'
    moves += 1
    pattern = pattern[spot:]
    spot = pattern.find(search)

print moves

Submission status: Accepted

Solution code:
i0 = ''
change = -1
stones = input()
for i in stones:
    if i != i0:
        change += 1
    i0 = i
print(change)

Submission status: Accepted

Solution code:
x = raw_input()
out = 0
curchar = x[0]
for d in range(0, len(x)):
 if curchar != x[d]:
  curchar = x[d]
  out += 1
print(out)

Submission status: Accepted

Solution code:
S = input()
runs = 0
b = S[0] == 'B'
for s in S:
    if (s == 'B') != b:
        b = (s == 'B')
        runs += 1
print(runs)

Submission status: Accepted

Solution code:
board = input()


changes = 1
currSeq = board[0]

for i in range(1, len(board)):
	current = board[i]
	if current != currSeq:
		changes += 1
		currSeq = current

print(changes - 1)

Submission status: Accepted

Solution code:
board = input()

changes = 1
currSeq = board[0]

for i in range(1, len(board)):
	current = board[i]
	if current != currSeq:
		changes += 1
		currSeq = current

print(changes - 1)

Submission status: Accepted

Solution code:
strs = raw_input().strip()
n = len(strs)
bbb = 0
for i in xrange(n-1):
    if strs[i] != strs[i+1]:
        bbb+=1
print(bbb)

Submission status: Accepted

Solution code:
a = raw_input()
c = 0
last = a[0]
for i in a:
    if i != last:
        c += 1
        last = i
print c

Submission status: Accepted

Solution code:
s = input()

res = 0
c = s[0]
for c2 in s[1:]:
    if (c == c2):
        continue
    c = c2
    res += 1

print(res)

Submission status: Accepted

Solution code:
s = input()

diffcnt = 0
before = None
for c in s:
    if before is None:
        before = c
        continue
    if before != c:
        diffcnt += 1
    before = c
print(diffcnt)

Submission status: Accepted

Solution code:
S = input()

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

print(cnt)

Submission status: Accepted

Solution code:
l = raw_input().strip()
last = l[0]
ansl = 0
for x in l:
	if x != last:
		ansl += 1
		last = x
l = l[::-1]
last = l[0]
ansr = 0
for x in l:
	if x != last:
		ansr += 1
		last = x
print(min(ansl, ansr))

Submission status: Accepted

Solution code:
from collections import defaultdict
from itertools import groupby


def main():
    S = input()
    print(len([k for k, g in groupby(S)]) - 1)


if __name__ == '__main__':
    main()

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 = raw_input()
count = 0
prev = ''
for c in S:
    if c != prev: count += 1
    prev = c
print count - 1

Submission status: Accepted

Solution code:
a = input()
b = list(a)
counter = 0
str = b[0]
for i in range(len(b)):
    if(i==0):
        continue

    if(str != b[i]):
        counter += 1

    str = b[i]
print(counter)

Submission status: Accepted

Solution code:
S = raw_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 -*-

s = raw_input()

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

Submission status: Accepted

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

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

print(str(res))

Submission status: Accepted

Solution code:
def main():
    s=input()
    n=len(s)
    if n == 1:
        print(0)
        return
    t=s[0]
    for _ in range(n-1):
        i = _ + 1
        if s[i] != s[i-1]:
            t += s[i]

    w,b = 0,0
    for c in t:
        if c == 'W':
            w = w + 1
        else:
            b = b + 1
    print(w+b-1)
            
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
s = input()


def main(s):
    count = 0
    prev = s[0]

    for c in s:
        if prev != c:
            count += 1
            prev = c

    return count


print(main(s))

Submission status: Accepted

Solution code:
s = input()


def main(s):
    prev, s = s[0], s
    count = 0
    for c in s:
        if c != prev:
            count += 1
            prev = c
    return count



print(main(s))

Submission status: Accepted

Solution code:
import sys

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def solve():
    S = input()
    cnt = 0

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

    print(cnt)

if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-
import re
S = input()
b = re.findall('B+',S)
w = re.findall('W+',S)
ans = len(b)+len(w)-1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
B = []
Nc = 0

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

Submission status: Accepted

Solution code:
#003
list = list(input())
result = 0

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

print(result)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
S = raw_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()
n = len(s)

print(sum([ 1 for i in range(n-1) if s[i] != s[i+1]]))

Submission status: Accepted

Solution code:
from collections import defaultdict


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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
tmp = map(str,raw_input())
zero = tmp[0]
count = 1
for n in tmp:
    if zero != n:
        count = count + 1
        zero = n
if count != 0:
    print (count - 1)
else:
    print (count)

Submission status: Accepted

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

buf = bord[0]
count = 0
for i in bord:
	if buf == i:
		continue
	else:
		buf = i
		count = count + 1
		continue
print(count)

Submission status: Accepted

Solution code:
import sys
wb = sys.stdin.readline()
count = 0
for i in xrange(1,len(wb)-1):
    if wb[i-1] != wb[i]:
        count += 1
print count

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=list(input())

def transform(S):
    r_S=[S[0]]
    now_c=S[0]
    for item in S:
        if now_c==item:
            pass
        else:
            now_c=item
            r_S.append(item)

    return r_S

print(len(transform(S))-1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
(lambda line: print(line.count("WB") + line.count("BW")))(input())

Submission status: Accepted

Solution code:
line = input()
target = line[0]
count = 0

for x in line:
    if x != target:
        count += 1
        target = x
print(count)

Submission status: Accepted

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

cpr=[]
prev=''
for i in xrange(N):
    curr=S[i]
    if curr != prev:
        cpr.append(curr)
        prev=curr
r=len(cpr)-1
print(r)

Submission status: Accepted

Solution code:
x = raw_input()
y = []

y.append(x[0])

for i in range(len(x)):
	if y[-1] != x[i]:
		y.append(x[i])

print len(y)-1

Submission status: Accepted

Solution code:
# coding: utf-8
"""1D Reversi

@author: hijiri.n
@modified: 11-19-2016

"""

cnt = 0
sw = ""

for s in input().strip():
    if sw != s:
        sw = s
        cnt += 1

print(cnt - 1)

Submission status: Accepted

Solution code:
# coding: utf-8

stones = input().strip()
counter, switch = 0, stones[0]

for s in stones[1:]:
    if switch != s:
        switch = s
        counter += 1

print(counter)

Submission status: Accepted

Solution code:

s=input()

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

print(count)

Submission status: Accepted

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

def main():
    S = input()

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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()
print(S.count('BW')+S.count('WB'))

Submission status: Accepted

Solution code:
#abc047_c

s=raw_input()
cnt=0
for i in xrange(len(s)-1):
 if s[i]!=s[i+1]:
  cnt+=1
print cnt

Submission status: Accepted

Solution code:
def opposite(col):
    if col == "B":
        return "W"
    elif col == "W":
        return "B"
    else:
        print("error")

board = list(input())
board_l = board[:]
board_r = board[:]
left_side = board_l[0]
right_side = board_r[-1]
s = len(board)
counter_l = 0
counter_r = 0
i = 0
fin_flag = False
while fin_flag == False:
    if board_l[i] == left_side:
        pass

    else:
        counter_l += 1
        left_side = board_l[i]
        # #just for fun.
        # for j in range(i):
        #     board_l[j] = left_side

    if board_r[-i-1] == right_side:
        pass

    else:
        counter_r += 1
        right_side = board_r[-i-1]
    #     #just for fun
    #     print("-i-1",-i-1)
    #     for j in range(1,abs(-i-1)):
    #         board_r[-j] = right_side

    # print("board_l",board_l)
    # print("board_r",board_r)
    if i == s-1:
        if counter_l > counter_r:
            print(counter_l)
        else:
            print(counter_r)
        fin_flag = True
    i += 1

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
line = input()

count = 0

if 'WB' in line:
    count += line.count('WB')
if 'BW' in line:
    count += line.count('BW')
else:
    pass

if not 'W' in line:
    print(0)
elif not 'B' in line:
    print(0)
else:
    #ans = int((int(count / 2) + 1) * 4 - 3)
    ans = count
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
S = input()
S1 = np.array(S.split("W"))
S2 = np.array(S.split("B"))
if len(S1) == 1 or len(S2) == 1:
    print(0)
else:
    num1 = len(S1[S1 != '']) * 2 - 1
    if S1[0] == '' and S1[-1] == '':
        num1 += 1
    if num1 < 0:
        num1 = 0
    num2 = len(S2[S2 != '']) * 2 - 1
    if S2[0] == '' and S2[-1] == '':
        num2 += 1
    if num2 < 0:
        num2 = 0
    if num2 < num1:
        print(num2)
    else:
        print(num1)

Submission status: Accepted

Solution code:
def line(s):
    ret = [0] * len(s)
    for i in range(len(s)):
        ret[i] = 0 if s[i] == 'W' else 1

    return ret

def count(arr):
    c = 0
    for i in range(len(arr)-1):
        if arr[i+1] != arr[i]:
            c += 1
    return c

if __name__ == '__main__':
    s = raw_input()
    arr = line(s)
    print(count(arr))

Submission status: Accepted

Solution code:
def func(string):
	count = 0
	p = string[-1]
	for i in range(len(string)-2,-1,-1):
		if p!=string[i]:
			count+=1
			p=string[i]
	return count


string = str(input())
print(func(string))

Submission status: Accepted

Solution code:
import re
s = input()
W = re.compile(r'W{2,}')
B = re.compile(r'B{2,}')
s = W.sub('W', s)
s = B.sub('B', s)
print(len(s)-1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = raw_input()

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

print ans

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = str(input().split())
result = S.count('WB') + S.count('BW')
print(result)

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

Submission status: Accepted

Solution code:
s = str(input())
k =s[0]
count = 0
while s :
    s = s[1:]
    if s != '':
        if k != s[0]:count +=1
        k =s[0]
print(count)

Submission status: Accepted

Solution code:
s = input()

count = 0
now = s[0]
for i, c in enumerate(s[1:]):
    if now != c:
        now = c
        count += 1
print(count)

Submission status: Accepted

Solution code:
import sys
line = sys.stdin.readline()
inp = line.rstrip()

#print (inp)
check = ""
for s in inp:
    if check=="" or check[-1]!=s:
        check += s
    elif check[-1]==s:
        continue

#print (check)
print (len(check)-1)

Submission status: Accepted

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

S = str(input())
n = len(S)
T = ''
c = ''

for i in range(n):
	if S[i] != c:
		c = S[i]
		T += S[i]

print(len(T) - 1)

Submission status: Accepted

Solution code:
a=[]
for i in list(input()):
	a.append(i)

memo=""
c = 0
for i in a:
	if i==memo:
		continue
	else:
		memo=i
		c+=1

print(c-1)

Submission status: Accepted

Solution code:
S = list(input())

total = 0
prechar = S[0]
for c in S[1:]:
    if c != prechar:
        total += 1
        prechar = c

print(total)

Submission status: Accepted

Solution code:
import re
str = input()
b = re.split("W+",str)
w = re.split("B+",str)
bcnt = len(b)-b.count("")
wcnt = len(w)-w.count("")

print(bcnt+wcnt-1)

Submission status: Accepted

Solution code:
S = raw_input()
prev = ""
count = -1
for s in S:
    if s != prev:
        prev = s
        count += 1

print count

Submission status: Accepted

Solution code:
# C
S = input()
temp = S[0]
count = 0
for x in S:
    if x != temp: count += 1
    temp = x
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
dat = raw_input()

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

ans = 0
now = dat[0]

for a in range(1,len(dat)):
  if now != dat[a]:
    ans += 1
    now = dat[a]

print ans

Submission status: Accepted

Solution code:
# coding: utf-8

S = raw_input()

ans = 0

for i in xrange(len(S) - 1):
    if S[i:i+2] == "WB" or S[i:i+2] == "BW":
        ans += 1

print ans

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    s = input()
    s0 = s[0]
    count = 0
    for n in s:
        if s0 != n:
            count += 1
        s0 = n
    print(count)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# coding: utf-8

def main():
    reverse_count = 0
    s = raw_input()
    for i in range(len(s)-1):
        c, n_c = s[i], s[i+1]
        if c != n_c:
            reverse_count += 1
    print reverse_count

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = raw_input()
res = -1
now = ""
for i in s:
    if i != now:
        res += 1
        now = i
print res

Submission status: Accepted

Solution code:

s = input()
prev = 'N'
ans = -1


for s_i in s:
    if prev != s_i:
        prev = s_i
        ans += 1

print(ans)

Submission status: Accepted

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

Submission status: Runtime Error

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: Runtime Error

Solution code:
n = input()
gr = itertools.groupby(n)
print(len(gr)-1)

Submission status: Runtime Error

Solution code:
	def main():
    s = str(input())
    b_count = s.count('B')
    w_count = len(s) - b_count

    if b_count == len(s) or w_count == len(s):
        count = 0
    else:
        count = 0
        index = 0
        alp = s[index]

        while True:
            if b_count == 0 or w_count == 0:
                break
            else:
                if s[index] == 'B':
                    b_count -= 1
                else:
                    w_count -= 1

                if s[index] == alp:
                    index += 1
                    continue
                else:
                    count += 1
                    alp = s[index]
                    index += 1

        if not (b_count == 0 and w_count == 0):
            count += 1

    print(count)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <string>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    int ans = 0;
    cin >> s;
    rep(i,s.size()-1) {
        if (s[i] != s[i+1]) {
            ans++;
        }
    }
    cout << ans << "\n";
}

Submission status: Runtime Error

Solution code:
#include <iostream>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    int ans = 0;
    cin >> s;
    rep(i,s.size()-1) {
        if (s[i] != s[i+1]) {
            ans++;
        }
    }
    cout << ans << "\n";
}

Submission status: Runtime Error

Solution code:
S = input()
cntb = 1000000 if if S[0] == "B" and S[-1] == "B" else 0
cntw = 1000000 if S[0] == "W" and S[-1] == "W" else 0
for s in S.split("B"):
  if s != "":
    cntb += 1
for s in S.split("W"):
  if s != "":
    cntw += 1
print(min(cntb, cntw))

Submission status: Runtime Error

Solution code:
S = input()
X = S[0]
ans = 0
while 1:    
    for i in range(S):
        if S[i] != X:
            ans += 1
            X =S[i]
            S = S[i:]
            break
    else:
        break
print(ans)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3

# from numba import njit

# input = stdin.readline

def calcGroup(s):
  whiteCount = 0
  blackCount = 0
  prev = ""
  for i in range(len(s)):
    if s[i] == prev:
      pass
    else:
      if s[i] = "":
        pass
      elif s[i] = "W":
        whiteCount += 1
      elif s[i] = "B":
        blackCount += 1
      else:
        raise ValueError
    prev = s[i]
  return whiteCount,blackCount

# @njit
def solve(s):
  # white,black = calcGroup(s)
  return min(calcGroup(s))



def main():
  s = input()
  print(solve(s))
  return

if __name__ == '__main__':
  main()

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3

# from numba import njit

# input = stdin.readline

def calcGroup(s):
  whiteCount = 0
  blackCount = 0
  prev = ""
  for i in range(len(s)):
    if s[i] == prev:
      pass
    else:
      if s[i] = "W":
        whiteCount += 1
      elif s[i] = "B":
        blackCount += 1
      else:
        raise ValueError
    prev = s[i]
  return whiteCount,blackCount

# @njit
def solve(s):
  # white,black = calcGroup(s)
  return min(calcGroup(s))



def main():
  s = input()
  print(solve(s))
  return

if __name__ == '__main__':
  main()

Submission status: Runtime Error

Solution code:
#import
#import math
#import numpy as np
#= int(input())
S = input()
#= map(int, input().split())
#= list(map(int, input().split()))
#= [input(), input()]
#= [list(map(int, input().split())) for _ in range(N)]
#= {i:[] for i in range(N)}

s = S[0]

r = 0

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

    s = S[i]

print(res)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def solve(n):
    if n == 1:
        return 0
    else:
        if S[n - 2] == S[n - 1]:
            return solve(n - 1)
        else:
            return solve(n - 1) + 1


if __name__ == "__main__":
    S = input()
    first_s = S[0]
    S = [1 if first_s == s else 0 for s in S]

    print(solve(len(S)))