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):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

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


def f():
    s = input()
    t = ''
    r = -1
    for c in s:
        if t != c:
            r += 1
            t = c
    return r

print(f())

Solution (Python):

S = input()
p = None
n = 0
for s in S:
    if s != p:
        n += 1
        p = s
print(n - 1)

Solution (Python):
s = input()
ans = -1
b = ""
for l in s:
	if b != l:
		ans += 1
	b = l
print(ans)

Solution (Python):
from collections import Counter
s = input()
cnt_wb = Counter(s)

if cnt_wb["W"] == len(s) or cnt_wb["B"] == len(s):
    print(0)
else:
    prev = s[0]
    cnt = 0
    for i in range(1, len(s)):
        if prev != s[i]:
            prev = s[i]
            cnt += 1
    print(cnt)

Solution (Python):
s = raw_input().strip()
c = 0
for i in xrange(len(s) - 1):
    c += s[i] != s[i+1]
print c

Solution (Python):
s=raw_input()
l=0
r=len(s)-1

news=""
i=0
while i<len(s):
    if s[i]=="W":
        while i<len(s) and s[i]=="W":
            i+=1
        news+=s[i-1]
    else:
        while i<len(s) and s[i]=="B":
            i+=1
        news+=s[i-1]
print(len(news)-1)

Solution (Python):
def solve(s):
    ans = 0
    while len(s)>1:
        ans += s[0]!=s[1]
        s = s[1:]
    return ans

S = input()
print(solve(S))

Solution (Python):



def compute(s):
    board = [c == "W" for c in s]
    n = len(board)
    ans = 0
    for i in range(1, n):
        if board[i] != board[i - 1]:
            ans += 1
    return ans


def main():
    print(compute(input()))


if __name__ == '__main__':
    main()

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

s = raw_input().strip()
print(solve(s))

Solution (Python):
s=raw_input()
ans=0
t=''
for i in s:
    if t!='' and t!=i:
        ans+=1
    t=i
print ans

Solution (Python):



from __future__ import division, print_function, absolute_import, unicode_literals
s = input()
cnt = 0
for a, b in zip(s[:-1], s[1:]):
    if a != b:
        cnt += 1
print(cnt)

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

Solution (Python):



S = input()


prev = ''
new_S = ''
for ch in S:
    if ch != prev:
        new_S += ch
    prev = ch
print(len(new_S)-1)

Solution (Python):
s = list(raw_input())

count = 0



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

print count

Solution (Python):
import sys

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

last = None
res = 0
for i in range(len(line)):
    if last != line[i]:
        res += 1
    last = line[i]

print(res-1)

Solution (Python):
s = raw_input()
before = ''
ans = 0

for i in s:
    if i != before:
        ans += 1
        before = i
print ans-1

Solution (Python):
import itertools
S = input()
group = list(itertools.groupby(S))
print(len(group) - 1)

Solution (Python):
S = raw_input()
S_list = list(S)
x = S_list[0]
res = 0
for s in S_list:
    if s != x:
        res += 1
        x = s
print res

Solution (Python):
s = raw_input()

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

Solution (Python):



def rl(s): return xrange(len(s))

INF = 2147483647


import sys
stdin = sys.stdin

s = stdin.readline().strip()

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

Solution (Python):
s = raw_input()
count = 0
c = s[0]
for i in xrange(len(s)):
    if s[i] == c:
        continue
    count += 1
    c = s[i]
print count

Solution (Python):

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys

def s():
    return raw_input().strip()
def n():
    return int(raw_input())
def d():
    return float(raw_input())

def ls():
    return raw_input().strip().split()
def ln():
    return map(int, raw_input().strip().split())
def ld():
    return map(float, raw_input().strip().split())

def fs():
    return [raw_input().strip() for i in xrange(input())]
def fn():
    return [int(raw_input().strip()) for i in xrange(input())]
def fd():
    return [float(raw_input().strip()) for i in xrange(input())]

S = s()

count = 0
before = S[0]
for c in S:
    if c != before:
        count += 1
        before = c

print count

Solution (Python):
line = input()
s = len(line)
last = line[0]
count = 0
for letter in line:
    if letter!=last:
        last = letter
        count+=1
print(count)

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 = input()
now = s[0]
ans = 0
for c in s:
	if c != now:
		now = c
		ans += 1
print(ans)

Solution (Python):


s = input().strip()
cur = s[0]
cnt = 0
for c in s:
    if c != cur:
        cur = c
        cnt += 1
print(cnt)

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

Solution (Python):
import itertools
print(len(list(itertools.groupby(input()))) - 1)

Solution (Python):
from sys import exit, setrecursionlimit
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

setrecursionlimit(1000000)

S = input()
result = sum(S[i] != S[i-1] for i in range(1, len(S)))
print(result)