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: Wrong Answer

Solution code:
S='WBWBWBWBWBWB';
DifF=0;
First=S[0];
len=len(S)
End=S[len-1];
for i in range(len-1):
    if S[i]!=S[i+1]:
        DifF+=1;
print(DifF);

Submission status: Wrong Answer

Solution code:
S=input();
DifF=0;
DifE=0;
First=S[0];
len=len(S)
End=S[len-1];
if First==End:
    for i in range(len):
    	if S[i]!=First:
    		DifF+=1;
    		DifE+=1;
elif First!=End:
    for i in range(len):
    	if S[i]!=First:
    		DifF+=1;
    	elif S[i]==First:
    	    DifE+=1;
if DifE >= DifF:
    print(DifF);
else:
    print(DifE);

Submission status: Wrong Answer

Solution code:
s = input()
prev = s[0]
ans = 0

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

Submission status: Wrong Answer

Solution code:

s = raw_input()
cnt = 0
last = s[0]
 
for c in s[1:]:
    if c != last:
        cnt = cnt+1
    last = c
print cnt+1

Submission status: Wrong Answer

Solution code:
s = raw_input()
cnt = 0
last = s[0]
 
for c in s[1:-1]:
    if c != last:
        cnt = cnt+1
    last = c
print cnt

Submission status: Wrong Answer

Solution code:
print('AAA')

Submission status: Wrong Answer

Solution code:

import  numpy as np
print('hoge!')

Submission status: Wrong Answer

Solution code:
a=raw_input()
ary=list(a)
count = 0

def countStr(arys):
  cW=0
  cB=0
  for i in arys:
    if i == "B":
      cB += 1
    else:
      cW += 1
  return cW, cB

while len(set(ary)) != 1:
  count += 1
  W, B=countStr(ary)
  if ary[len(ary)-1] == "W":
    ary.append("B")
    m = 2
    for i in ary:
      if ary[len(ary)-m] == "W":
        ary[len(ary)-m] = "B"
        m += 1
      else:
        break
  else:
    ary.append("W")
    m=2
    for i in ary:
      if ary[len(ary)-m] == "B":
        ary[len(ary)-m] = "W"
        m += 1
      else:
        break
  
print ary
print count

Submission status: Wrong Answer

Solution code:
def main():
    s = raw_input()
    check_b = lambda x: x=='B'
    check_w = lambda x: x=='W'
    if all(map(check_b, list(s))) or all(map(check_w, list(s))):
        return 0

    work = list(s)[:]
    print 1



if __name__ == '__main__':
    print main()

Submission status: Time Limit Exceeded

Solution code:
def same(board):
  for i in range(len(board)):
    if board[i] != board[0]:
      return False
  return True
def change(board,to):
  p = board.index(to)
  board[:0] = to
  for i in range(p+1):
    board[i] = to
  return(board)
board = []
t = [board.append(n) for n in input()]
p = 0
n = 0
while True:
  if (same(board) == True):
    break
  elif board[0] == 'B':
    board = change(board,'W')
  else:
    board= change(board,'B')
  n += 1
print(str(n))

Submission status: Time Limit Exceeded

Solution code:
def same(board):
  for i in range(len(board)):
    if board[i] != board[0]:
      return False
  return True
board = []
t = [board.append(n) for n in input()]
p = 0
n = 0
while True:
  if (same(board) == True):
    break
  elif board[0] == 'B':
    p = board.index('W')
    board[:0] = 'W'
    for i in range(p+1):
      board[i] = 'W'
    n += 1
  else:
    p = board.index('B')
    board[:0] = 'B'
    for i in range(p+1):
      board[i] = 'B'
    n += 1
print(str(n))

Submission status: Time Limit Exceeded

Solution code:
while True:
  pass

Submission status: Time Limit Exceeded

Solution code:
s = input()
ans = 0
while len(set(s)) > 1:
    if s[-1] == "W":
        b = s.rfind("B") + 1
        s = s[:b] + "B" * (len(s[b:]) + 1)
    else:
        b = s.rfind("W") + 1
        s = s[:b] + "W" * (len(s[b:]) + 1)
    ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
a=raw_input()
ary=list(a)
count = 0

tmp=""
for i,v in enumerate(ary):
  if v == tmp:
    del(ary[i])
    tmp=v
  else:
    tmp=v

def countStr(arys):
  cW=0
  cB=0
  for i in arys:
    if i == "B":
      cB += 1
    else:
      cW += 1
  return cW, cB

while len(set(ary)) != 1:
  count += 1
  #W, B=countStr(ary)

  
  if ary[len(ary)-1] == "W":
    ary.append("B")
    m = 2
    for i in ary:
      if ary[len(ary)-m] == "W":
        ary[len(ary)-m] = "B"
        m += 1 
      else:
        break
  else:
    ary.append("W")
    m=2
    for i in ary:
      if ary[len(ary)-m] == "B":
        ary[len(ary)-m] = "W"
        m += 1
      else:
        break
  
print count

Submission status: Time Limit Exceeded

Solution code:
a=raw_input()
ary=list(a)
count = 0

def countStr(arys):
  cW=0
  cB=0
  for i in arys:
    if i == "B":
      cB += 1
    else:
      cW += 1
  return cW, cB

while len(set(ary)) != 1:
  count += 1
  #W, B=countStr(ary)

  if ary[len(ary)-1] == "W":
    ary.append("B")
    m = 2
    for i in ary:
      if ary[len(ary)-m] == "W":
        ary[len(ary)-m] = "B"
        m += 1 
      else:
        break
  else:
    ary.append("W")
    m=2
    for i in ary:
      if ary[len(ary)-m] == "B":
        ary[len(ary)-m] = "W"
        m += 1
      else:
        break
  
print count

Submission status: Time Limit Exceeded

Solution code:
S = list(raw_input())

if len(set(S)) == 1:
    print 0
else:
    count = 0
    while len(set(S)) > 1:
        if S[-1] == 'W':
            added = 'B'
        else:
            added = 'W'
        S += added
        count += 1

        i = -2
        while S[i] != added:
            if S[i] == 'W':
                S[i] = 'B'
            else:
                S[i] = 'W'
            i -= 1
        # break
    print count

Submission status: Time Limit Exceeded

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

def f(c, bw):
    r = ""
    b = 1
    if bw[0] != c:
        for i in bw:
            if b and i != c:
                r += c
            else:
                b = 0
                r += i
        return 1, r
    elif bw[-1] != c:
        for i in bw[::-1]:
            if b and i != c:
                r += c
            else:
                b = 0
                r += i
        return 1, r
    return 0, bw
    

bw = input()
cnt = 0
c = ('B', 'W')
while ('B' in bw) and ('W' in bw):
    a = c[cnt%2]
    b, bw = f(a, bw)
    cnt += b
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
s = input()
while "BB" in s or "WW" in s:
	s.replace("BB", "B")
	s.replace("WW", "W")

print(len(s)-1)

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

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(input())

if S[0] == "B":
    flg = True
else:
    flg = False

ans = 0
for i in range(1, len(S)):
    s = S[i]
    if s == "B":
        tmp = True
    else:
        tmp = False

    if flg != tmp:
        ans += 1
        flg = not flg

print(ans)

Submission status: Accepted

Solution code:
s = input()
print(sum(x != y for x, y in zip(s, s[1:])))

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:
# coding: utf-8
# Your code here!
s = str(input())
lst = []
for i in s:
    if not lst:
        lst.append(i)
    if i != lst[-1]:
        lst.append(i)
        
print(len(lst)-1)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

#n, = map(int,readline().split())

s = input()

ans = 0
for i,j in zip(s,s[1:]):
    if i!=j: ans+=1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import groupby

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(str(input()))
l = []
ls = len(S)
B,W = 0,0
for i in range(ls):
  if S[i] == "B":
    B += 1
    if W != 0:
      l.append('W')
      W = 0
  else:
    W += 1
    if B != 0:
      l.append('B')
      B = 0
  if i == ls-1:
    if S[i] == "B":
      l.append("B")
    elif S[i] == "W":
      l.append("W")
ls = len(l)

print(ls-1)

Submission status: Accepted

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

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

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
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

s=list(ss())
cnt=0
chk=True
if s[0]=="B":
    chk=False
for i in range(len(s)-1):
    if chk==True and s[i+1]=="B":
        chk=False
        cnt+=1
    elif chk==False and s[i+1]=="W":
        chk=True
        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()
l = [S[0]]

for i in range(1,len(S)):
    if (S[i] != l[len(l)-1]):
        l.append(S[i])

print(len(l)-1)

Submission status: Accepted

Solution code:
def solve():
    S = input()
    
    ans = 0
    p_char = S[0]
    for char in S[1:]:
        if p_char != char:
            ans += 1
            p_char = char
    print(ans)


if __name__ == '__main__':
    solve()

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:
#coding: utf-8
S = input()
old = 'init'
ans = -1
for s in S:
    if old!=s:
        ans += 1
    old = s
print (ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import _collections
import string
from functools import lru_cache
import heapq

class cin():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def mapInt():
        return [int(x) for x in cin.string().split()]
    def stringList(n):
        return [input() for i in range(n)]
    def intListList(n):
        return [cin.mapInt() for i in range(n)]
    def intColsList(n):
        return [int(input()) for i in range(n)]
        
class Math():
    def gcd(a,b):
        if b == 0:
            return a
        return Math.gcd(b,a % b)
    def lcm(a,b):
        return (a * b) // Math.gcd(a,b)
    def roundUp(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Math.roundUp(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3,d + 1,2):
            if n % i == 0:
                return False
        return True


MOD = int(1e09) + 7

def main():
    S = cin.string()
    N = len(S)
    ans = 0
    for i in range(N - 1):
        if S[i] != S[i + 1]:
            ans +=1
    print(ans)
    return

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
S = input()

con = 0

latest = S[0]

for i in S:
  if i != latest:
    con += 1
    latest = i
    
print(con)

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:
from collections import Counter

S = input()
c = Counter(S)

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

cbi = Counter([S[i:i+2] for i in range(len(S) - 1)])
counter = 0
if 'BW' in cbi:
    counter += cbi['BW']
if 'WB' in cbi:
    counter += cbi['WB']
print(counter)

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.readline
S = readline().strip()

pre = None
ans = -1
for s in S:
    if s != pre:
        ans += 1
    pre = s
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 = 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()
cnt=1;col=S[0]
for c in S[1:]:
    if c!=col:
        col=c
        cnt+=1
print(cnt-1)

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:
def slove():
    import sys
    input = sys.stdin.readline
    s = str(input().rstrip('\n'))
    cnt = 0
    for i in range(1, len(s)):
        if s[i] != s[i-1]:
            cnt += 1
    print(cnt)


if __name__ == '__main__':
    slove()

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()
print(sum(int(a!=b) for a,b, in zip(S,S[1:])))

Submission status: Accepted

Solution code:
S = input()
ans = 0
for k in range(1,len(S)):
    if S[k-1] != S[k]:
        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();print(s.count("BW")+s.count("WB"))

Submission status: Accepted

Solution code:
S = str(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:
uniq = []

for c in input():
    if not uniq:
        uniq += c
    elif uniq[-1] != c:
        uniq += c

print(len(uniq)-1)

Submission status: Accepted

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

s = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
#ABC130C
import sys


hoge=input()
#tmp = input().split()
#hoge = list(map(lambda a: int(a), tmp))
#n=hoge[0]
#m=hoge[1]

n=len(hoge)

ans=0
for i in range(0,n-1):
	if(hoge[i]!=hoge[i+1]):
		ans+=1
print(ans)

Submission status: Accepted

Solution code:
S=input()
mode=S[0]
cnt=0
for i in range(len(S)):
    if S[i]!=mode:
        cnt+=1
        if mode=='B':
            mode='W'
        else:
            mode='B'
print(cnt)

Submission status: Accepted

Solution code:
S = input()

ans = 0
pre = ""
for s in S:
    if pre == "":
        pre = s
    elif pre != s:
        ans += 1
    pre = s

print(ans)

Submission status: Accepted

Solution code:
s = list(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:
# coding: utf-8
# Your code here!

S = list(input())
S_len = len(S)
tmp = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = 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:
# ARC063C - 一次元リバーシ / 1D Reversi
def main():
    S = input()
    print(S.count("BW") + S.count("WB"))


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:
# ARC063C - 一次元リバーシ / 1D Reversi
S = input()
print(S.count("BW") + S.count("WB"))

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 = list(input())
N = len(S)
print(sum([S[x]!=S[x+1] for x in range(N-1)]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
if len(S) == 1:
    print(0)
else:
    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(len(S)-1):
    if S[i] != S[i+1]:
        count += 1
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
pre = 0
ans = -1
for i in s:
    if i != pre:
        ans += 1
    pre = i
print(ans)

Submission status: Accepted

Solution code:
S = input()

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

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 = [i for i in input()]
ans = 0
for i in range(len(S)-1):
    if S[i]=="W" and S[i+1]=="B":
        ans+=1
    elif S[i]=="B" and S[i+1]=="W":
        ans+=1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

Solution code:
s=input()
w=b=False
cnt=0
for i in s:
  if i=="B":
    if w==True:
      cnt+=1
      w=False
      b=True
    else:
      b=True
  else:
    if b==True:
      cnt+=1
      b=False
      w=True
    else:
      w=True
print(cnt)

Submission status: Accepted

Solution code:
S = input()
print(sum([a!=b for a,b in zip(S[:-1],S[1:])]))

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

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()
Slen = len(S)
cnt = 0
index = 0
if S[0] == "B":
    while index <= Slen-2:
        if S[index] == "B" and S[index+1] == "W":
            cnt += 1
            index += 2
        else:
            index += 1
    if S[-1] == "W":
        print(str(cnt*2-1))
    else:
        print(str(cnt*2))
else:
    while index <= Slen-2:
        if S[index] == "W" and S[index+1] == "B":
            cnt += 1
            index += 2
        else:
            index += 1
    if S[-1] == "B":
        print(str(cnt*2-1))
    else:
        print(str(cnt*2))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
print([ c != d for c, d in zip(s[:-1], s[1:])].count(True))

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

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

Submission status: Accepted

Solution code:
ls=input().strip()
a=ls[0]
b=0
for i in ls[1:]:
     if i!=a:
          b+=1
          a=i
print(b)

Submission status: Accepted

Solution code:
ls=input().strip()
a=ls[0]
b=0
def fun():
     print('a')
     print('b')
for i in ls[1:]:
     if i!=a:
          b+=1
          a=i
print(b)

Submission status: Accepted

Solution code:
s_long = input()

count = 0
prev = ''

for s in s_long:
    if prev == '':
        prev = s
        continue

    if prev != s:
        count += 1
        prev = s

print(count)

Submission status: Accepted

Solution code:
# ARC 063
S = input()
count = 0
stn = S[0]
i = 1
while i<len(S):
    while i<len(S) and stn==S[i] : i+=1 # 色が変わるまで
    if i<len(S): 
        count += 1
        stn = S[i]
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()

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

print(ans)

Submission status: Accepted

Solution code:
s = input()

stones = [1 if v == 'W' else 0 for v in s]

cnt = 0
for a, b in zip(stones, stones[1:]):
    if a ^ b:
        cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
s = input()
a = s.count("B")
b = s.count("W")
n = len(s)
if a == len(s) or b == len(s):
    print(0)
    exit()
ans = 0
ans2 = 0
for i in range(1,n):
    if s[i] != s[i-1]:
        ans+=1
for i in range(n-2,-1,-1):
    if s[i] != s[i+1]:
        ans2+=1
print(min(ans,ans2))

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict
import math
def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()
def IIR(n): return [II() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
mod = 1000000007

#A
"""
a,b = LS()
c = int(a+b)
for i in range(1,1000):
    if i * i == c:
        print("Yes")
        quit()
print("No")
"""

#B
"""
a,b = LI()
if a*b <= 0:
    print("Zero")
else:
    if b < 0:
        if (a-b) %2 == 1:
            print("Positive")
        else:
            print("Negative")
    else:
        print("Positive")
"""

#C
"""
n = II()
s = SR(n)
march = [[] for i in range(5)]
ch = list("MARCH")
for i in s:
    for j in range(5):
        if i[0] == ch[j]:
            march[j].append(i)
ans = 0
for i in range(5):
    for j in range(i):
        for k in range(j):
            if len(march[i])*len(march[j])*len(march[k]) == 0:
                break
            ans += len(march[i])*len(march[j])*len(march[k])
print(ans)
"""

#D
"""
n = II()
d = LIR(n)
q = II()
p = IIR(q)
d.insert(0,[0 for i in range(n+1)])
for i in range(n):
    d[i+1].insert(0,0)
for i in range(n):
    for j in range(n):
        d[i+1][j+1] += d[i+1][j]+d[i][j+1]-d[i][j]
ans = [0 for i in range(n**2+1)]

for a in range(n+1):
    for b in range(n+1):
        for c in range(a):
            for e in range(b):
                ans[(a-c)*(b-e)] = max(ans[(a-c)*(b-e)],d[a][b]-d[c][b]-d[a][e]+d[c][e])

for i in p:
    an = 0
    for a in range(i+1):
        an = max(an, ans[a])
    print(an)
"""
#E

s = list(S())
ans = -1
s.insert(0,0)
d = 0
for i in range(1,len(s)):
    if s[i] != d:
        d = s[i]
        ans += 1
print(ans)
#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T

Submission status: Accepted

Solution code:
#a
"""
import math
a, b = map(str, input().split())
j = int(a + b)
if math.sqrt(j).is_integer():
    print("Yes")
else:
    print("No")
"""

#b
"""
ans = ["Positive","Negative"]
a, b = map(int, input().split())
if 0 < a:
    print("Positive")
elif b >= 0:
    print("Zero")
else:
    print(ans[(b-a)%2-1])
"""

#C
"""
import itertools
n = int(input())
MARCH = ["M", "A", "R", "C", "H"]
march = [0 for _ in range(5)]
for i in range(n):
    s = input()
    if s[0] in MARCH:
        march[MARCH.index(s[0])] += 1
num = list(range(5))
a = list(itertools.combinations(num, 3))
ans = 0
for i in a:
    bf = 1
    for k in i:
        bf *= march[k]
    ans += bf
print(ans)
"""

#D
"""
n = int(input())
D = [list(map(int, input().split())) for _ in range(n)]
q = int(input())
p = [int(input()) for _ in range(q)]
for i in range(n):
    D[i].insert(0, 0)
    D[i].insert(n+1, 0)
D.insert(0,[0 for _ in range(n + 2)])
D.insert(n + 2, [0 for _ in range(n + 2)])
print(D)
"""

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

Submission status: Accepted

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

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

before = S[0]
ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
a=list(input())

n = len(a)

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

print(res)

Submission status: Accepted

Solution code:
ar = list(input())
n = ""
count = 0
for r in ar:
    if n != r:
        count += 1
        n = r
print(count-1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

before = None
ans = 0
for c in s:
    if c != before:
        ans += 1
        before = c
print(ans -1)

Submission status: Accepted

Solution code:
S=input().strip()
N=len(S)
snum=1
ns=S[0]
def solve(S):
    global ns,snum
    for i in range(N):
        #print(ns)
        if ns!=S[i]:
            snum+=1
            ns=S[i]
    #if snum==1 and S[0]=='B':
    #    snum=3
    #    return snum
    return snum

print(solve(S)-1)

Submission status: Accepted

Solution code:

import sys
import collections
import itertools
import math
import re
from collections import Counter
from collections import deque

MOD = 10 ** 9 + 7

S = input()

l = [S[0]]

for s in S:
    if l[-1] != s:
        l.append(s)

print(len(l) - 1)

sys.exit(0)