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

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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

Solution (Python):
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

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

Solution (Python):
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)

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

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

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

Solution (Python):
s = input()

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

print(res)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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))

Solution (Python):
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()

Solution (Python):
S = input()


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

Solution (Python):
S = raw_input()
count = 0
prev = ''
for c in S:
    if c != prev: count += 1
    prev = c
print count - 1

Solution (Python):
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)

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

Solution (Python):


s = raw_input()

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

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

Solution (Python):
S = str(input())

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

print(str(res))

Solution (Python):
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()

Solution (Python):
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))

Solution (Python):
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))

Solution (Python):
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()

Solution (Python):

import re
S = input()
b = re.findall('B+',S)
w = re.findall('W+',S)
ans = len(b)+len(w)-1
print(ans)

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

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

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

Solution (Python):

list = list(input())
result = 0

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

print(result)

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

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

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

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

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

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

Solution (Python):
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()

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

Solution (Python):
s=raw_input()
print sum([s[i]!=s[i+1] for i in range(len(s)-1)])

Solution (Python):

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)

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

print(k)

Solution (Python):
bord = input()

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

Solution (Python):
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

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

Solution (Python):
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)

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

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

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

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

Solution (Python):

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)

Solution (Python):
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

Solution (Python):

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

Solution (Python):


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

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

print(counter)

Solution (Python):

s=input()

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

print(count)

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

Solution (Python):

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

Solution (Python):
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))

Solution (Python):
s = input()
count = 0

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

print(count)

Solution (Python):
S=input()
print(S.count('BW')+S.count('WB'))

Solution (Python):


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

Solution (Python):
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]
        
        
        

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

    else:
        counter_r += 1
        right_side = board_r[-i-1]
    
    
    
    

    
    
    if i == s-1:
        if counter_l > counter_r:
            print(counter_l)
        else:
            print(counter_r)
        fin_flag = True
    i += 1

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

Solution (Python):
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

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

Solution (Python):
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

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

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

Solution (Python):
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)

Solution (Python):
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 = count
    print(ans)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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))

Solution (Python):
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))

Solution (Python):
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)

Solution (Python):
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

Solution (Python):
S = input()

ans = 0

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

print(ans)

Solution (Python):
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

Solution (Python):
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)

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

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

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
s = input()

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

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


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


print (len(check)-1)

Solution (Python):


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)

Solution (Python):
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)

Solution (Python):
S = list(input())

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

print(total)

Solution (Python):
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)

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

print count

Solution (Python):

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

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

Solution (Python):
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

Solution (Python):


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

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

Solution (Python):



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

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

Solution (Python):

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


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

print(ans)

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