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 sys, math
from collections import defaultdict
from itertools import product
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    S = input()
    print(sum(1 for i in range(len(S)-1) if S[i] != S[i+1]))

if __name__ == '__main__':
    main()

Solution (Python):
def resolve():
    S = input()
    
    prev_color = S[0]
    color_change_count = 0
    for s in S:
        if s != prev_color:
            color_change_count += 1
            prev_color = s
    print(color_change_count)

resolve()

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

Solution (Python):
S = input()
change = 0
flag = S[0]
for i in S[1:]:
    if i != flag:
        change +=1
        flag = i
print(change)

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

Solution (Python):
import sys
input=sys.stdin.readline
s=input().rstrip()
t=s[0]
ans=0
for i in range(1,len(s)):
    if s[i]!=t:
        t=s[i]
        ans+=1
print(ans)

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

check=S[0]
S_=check
for s in S[1:]:
    if check != s:
        check = s
        S_+=check
        
print(len(S_)-1)

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

Solution (Python):
S = input()

def calculate(s):
    categories = 0
    for i in range(len(s)):
        if i == 0:
            continue

        if s[i] != s[i-1]:
            categories += 1
            continue

    print(categories)



calculate(S)

Solution (Python):

from itertools import groupby

S = input()
grp = [k for k, _ in groupby(S)]
print(len(grp) - 1)

Solution (Python):
import sys
from itertools import groupby

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    S = readline().strip()

    print(len(list(groupby(S))) - 1)

    return


if __name__ == '__main__':
    main()

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

Solution (Python):
S = input()

current = S[0]
ans = 0
for s in S:
    if s != current:
        ans += 1
        current = s

print(ans)

Solution (Python):

import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil



import string

from bisect import bisect_left
MOD = int(1e9)+7
INF = float('inf')


def solve():
    
    s = input()
    seg = 1
    for i in range(1, len(s)):
        if s[i] != s[i-1]:
            seg += 1
    print(seg - 1)

t = 1

for case in range(1,t+1):
    ans = solve()


"""

azyxwvutsrqponmlkjihgfedcb

"""

Solution (Python):
import sys
def LS2(): return list(sys.stdin.readline().rstrip())  

S = LS2()

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

print(ans)

Solution (Python):
s = input()

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

print(ans)

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

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

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

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

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

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

Solution (Python):
s = input()
res = 0
st = s[0]

for v in s:
    if st != v:
        res += 1
        st = v
print(res)

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































def run_length_encoding(s):
    '''連長圧縮を行う
    s ... iterable object e.g. list, str
    return
    ----------
    s_composed,s_num,s_idx
    それぞれ、圧縮後の文字列、その文字数、その文字が始まるidx'''
    from itertools import groupby
    s_composed, s_sum = [], []
    s_idx = [0]
    for k, v in groupby(s):
        s_composed.append(k)
        
        
        

    
    return s_composed, s_sum, s_idx


S_composed, _, _ = run_length_encoding(input())
print(len(S_composed) - 1)

Solution (Python):
def run_length_encoding(s):
    '''連長圧縮を行う
    s ... iterable object e.g. list, str
    return
    ----------
    s_composed,s_num,s_idx
    それぞれ、圧縮後の文字列、その文字数、その文字が始まるidx'''
    from itertools import groupby
    s_composed, s_sum = [], []
    s_idx = [0]
    for k, v in groupby(s):
        s_composed.append(k)
        n = len(list(v))
        s_sum.append(n)
        s_idx.append(s_idx[-1] + n)

    
    return s_composed, s_sum, s_idx


S_composed, _, _ = run_length_encoding(input())
print(len(S_composed) - 1)

Solution (Python):





def run_length_encoding(s):
    '''連長圧縮を行う
    s ... iterable object e.g. list, str
    return
    ----------
    s_composed,s_num,s_idx
    それぞれ、圧縮後の文字列、その文字数、その文字が始まるidx'''
    s_composed, s_sum = [], []
    s_idx = [0]
    pre = s[0]
    cnt = 1
    for i, ss in enumerate(s[1:], start=1):
        if pre == ss:
            cnt += 1
        else:
            s_sum.append(cnt)
            s_composed.append(pre)
            s_idx.append(i)
            cnt = 1
            pre = ss
    s_sum.append(cnt)
    s_composed.append(pre)
    
    return s_composed, s_sum, s_idx






















S_composed, _, _ = run_length_encoding(input())
print(len(S_composed) - 1)

Solution (Python):





def run_length_encoding(s):
    '''連長圧縮を行う
    s ... iterable object e.g. list, str
    return
    ----------
    s_composed,s_num,s_idx
    それぞれ、圧縮後の文字列、その文字数、その文字が始まるidx'''
    s_composed, s_sum = [], []
    s_idx = [0]
    pre = s[0]
    cnt = 1
    for i, ss in enumerate(s[1:], start=1):
        if pre == ss:
            cnt += 1
        else:
            s_sum.append(cnt)
            s_composed.append(pre)
            s_idx.append(i)
            cnt = 1
            pre = ss
    s_sum.append(cnt)
    s_composed.append(pre)
    
    return s_composed, s_sum, s_idx






















S_composed, _, _ = run_length_encoding(input())
print(len(S_composed) - 1)

Solution (Python):































def run_length_encoding(s):
    '''連長圧縮を行う
    s ... iterable object e.g. list, str
    return
    ----------
    s_composed,s_num,s_idx
    それぞれ、圧縮後の文字列、その文字数、その文字が始まるidx'''
    from itertools import groupby
    s_composed, s_sum = [], []
    s_idx = [0]
    for k, v in groupby(s):
        s_composed.append(k)
        n = len(list(v))
        s_sum.append(n)
        s_idx.append(s_idx[-1] + n)

    
    return s_composed, s_sum, s_idx


S_composed, _, _ = run_length_encoding(input())
print(len(S_composed) - 1)

Solution (Python):































def run_length_encoding(s):
    '''連長圧縮を行う
    s ... iterable object e.g. list, str
    return
    ----------
    s_composed,s_num,s_idx
    それぞれ、圧縮後の文字列、その文字数、その文字が始まるidx'''
    from itertools import groupby
    s_composed, s_sum = [], []
    s_idx = [0]
    for k, v in groupby(s):
        s_composed.append(k)
        n = len(list(v))
        s_sum.append(n)
        s_idx.append(s_idx[-1] + n)

    
    return s_composed, s_sum, s_idx


S_composed, _, _ = run_length_encoding(input())
print(len(S_composed) - 1)

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

Solution (Python):
import sys

def main(s):
    counter=0
    cf=s[0]
    for x in s:
        if cf!=x:
            cf=x
            counter+=1
    return counter

s=sys.stdin.readline().strip()
print(main(s))

Solution (Python):
S=list(input())
ans=0
now=S[0]
for s in S:
  if s==now:
    continue
  ans+=1
  now=s
print(ans)

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

print(ans)

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

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

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

Solution (Python):
S=input()
ans=len(S)
now=S[0]
for s in S:
    ans-=s==now
    now=s
print(ans)

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):
from collections import deque
S = deque(list(input()))

ans = 0
s = S.popleft()
while S:
    n = S.popleft()
    if s != n:
        ans += 1
        s = n
print(ans)

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

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

Solution (Python):
S = input()
pres = S[0]
ans = 0
for s in S[1:]:
    if pres == s:
        continue
    else:
        pres = s
        ans += 1
print(ans)

Solution (Python):
import threading
import sys


def main():
    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

    S = input()
    first_s = S[0]
    S = [1 if first_s == s else 0 for s in S]

    print(solve(len(S)))


if __name__ == "__main__":

    sys.setrecursionlimit(1024 * 1024 * 2)
    threading.stack_size(128 * 1024 * 1024 * 2)
    threading.Thread(target=main).start()

Solution (Python):
import sys
import itertools

import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines



S = input()

i = 1
count = 1
while i < len(S):
    if S[i] != S[i - 1]:
        count += 1
    i += 1
print(count - 1)

Solution (Python):
s = input()

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

Solution (Python):
s = input()

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

Solution (Python):
s = input()

stone = [s[0]]
for i in range(1,len(s)):
    if s[i] != s[i - 1]:
        stone.append(s[i])
print(len(stone) - 1)

Solution (Python):
s = input()

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

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

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

print(count)

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

Solution (Python):
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() 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)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')

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

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

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

print(ans)

Solution (Python):
import bisect,copy,heapq,string
from collections import *
from math import *
from itertools import *
import sys
sys.setrecursionlimit(10 ** 6)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

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

print(c)

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

now = S[0]
ans = 0

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

print(ans)

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

Solution (Python):
S=input()
N=len(S)
ans=0

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

print(ans)

Solution (Python):
s = input()

ans = 0
bef = s[0]
for c in s[1:]:
    if bef != c:
        ans += 1
    bef = c

print(ans)

Solution (Python):
import re

S = input()
S = re.sub('[B]{2,}', 'B', S)
S = re.sub('[W]{2,}', 'W', S)

print(len(S)-1)

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

before = s[0]

for c in s[1:]:
    if c != before:
        ans += 1
        before = c

print(ans)

Solution (Python):
S = input()

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

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

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

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from itertools import groupby
    s = input()
    ans = len(list(groupby(s))) - 1
    print(ans)


if __name__ == '__main__':
    main()

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

Solution (Python):
S = input()
answer = 0
present_color = ''
for i in range(len(S)):
    if i == 0:
        present_color = S[i]
        continue
    if present_color != S[i]:
        answer += 1
    else:
        pass
    present_color = S[i]
print(answer)

Solution (Python):
l = list(input())
n = len(l)

seg = []
for i in range(n-1):
    if l[i] != l[i+1]:
        seg.append(i)
print(len(seg))

Solution (Python):
l = list(input())
n = len(l)

idx = 0
seg = []
while idx < n:
    while idx < n-1 and l[idx] == l[idx+1]:
        idx+=1
    seg.append(idx)
    idx+=1
print(len(seg)-1)

Solution (Python):





import math
import fractions
import sys
import bisect
import heapq  
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr



def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod



def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a


inf = 10 ** 18
mod = 10 ** 9 + 7

s = input()
pre = s[0]
if len(s) == 1:
    print(0)
    sys.exit()
else:
    ans=0
    for i in range(1,len(s)):
        if pre != s[i]:
            ans+=1
            pre = s[i]
    print(ans)

Solution (Python):
import itertools

S=input()

S_=itertools.groupby(S)
cnt=-1
for key,gr in S_:
	cnt+=1

print(cnt)

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

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

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

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

if N==1:
    print(0)
else:
    b = S[0]
    ans = 0
    for i in S[1:]:
        if i!=b:
            ans += 1
            b = i
    print(ans)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

s = readline().decode().rstrip()
cnt = 0
for i in range(1, len(s)):
    if s[i - 1] != s[i]:
        cnt += 1
print(cnt)

Solution (Python):





def run_length_encoding(s):
    '''連長圧縮を行う
    s ... iterable object e.g. list, str 
    return
    ----------
    s_composed,s_num,s_idx
    それぞれ、圧縮後の文字列、その文字数、その文字が始まるidx'''
    s_composed, s_sum = [], []
    s_idx = [0]
    pre = s[0]
    cnt = 1
    for i, ss in enumerate(s[1:], start=1):
        if pre == ss:
            cnt += 1
        else:
            s_sum.append(cnt)
            s_composed.append(pre)
            s_idx.append(i)
            cnt = 1
            pre = ss
    s_sum.append(cnt)
    s_composed.append(pre)
    
    return s_composed, s_sum, s_idx


S_composed, _, _ = run_length_encoding(input())
print(len(S_composed) - 1)

Solution (Python):
def main():
    S = list(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):
def main():
    S = list(input())
    r = 0

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

    S.reverse()
    l = 0

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

    print(min(r, l))
if __name__ == "__main__":
    main()

Solution (Python):
s = input()

if s[-1] == 'B':
   new = 'W'
else:
   new = 'B'

if s == s[0] * len(s):
   print(0)
   exit()

ans = 0
for i in reversed(range(len(s)-1)):
   if s[i] == new:
      ans += 1
      if new == 'B':
         new = 'W'
      else:
         new = 'B'
print(ans)

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

Solution (Python):

s=input()
a=s.count('BW')
b=s.count('WB')

print(a+b)

Solution (Python):
s = input()

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

Solution (Python):


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    S = input().strip()
    ans = 0
    for i in range(1, len(S)):
        if S[i] != S[i-1]:
            ans += 1
    return ans


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

Solution (Python):
import sys











stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def main():
    s = str(stdin.readline().rstrip())
    
    
    
    
    
    
    l = len(s)
    ans = 0
    for i in range(l-1):
        if s[i] != s[i+1]:
            ans += 1
    print(ans)

main()

Solution (Python):
import sys
import numpy as np
import random
from decimal import Decimal
import itertools
import re
import bisect
from collections import deque, Counter
from functools import lru_cache

sys.setrecursionlimit(10**9)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() 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)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
def SERIES(n): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ')
def GRID(h,w): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ').reshape(h,-1)[:,:w]
def GRIDfromString(h,w): return np.frombuffer(sys.stdin.buffer.read(), 'S1').reshape(h,-1)[:,:w]
MOD = 1000000007

def main():
	s_list = list(S())
	s_list2 = []
	s_list2.append(s_list.pop(0))
	for s in s_list:
		if s_list2[-1] != s:
			s_list2.append(s)
	print(len(s_list2)-1)



if __name__ == '__main__':
    main()

Solution (Python):
s = input()

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

Solution (Python):
S = input()

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

Solution (Python):
s=input()
cnt=0
i=0
j=s[0]
n=len(s)
while True:
  for k in range(i+1,n):
    if s[k]!=j:
      cnt+=1
      j=s[k]
      i=k
      break
  else:break
print(cnt)

Solution (Python):
s= input()

now = s[0]
ans = 0
for i in range(1,len(s)):
    if now == s[i]:
        pass
    elif now != s[i]:
        ans += 1
        flg = 1
        now = s[i]

print(ans)

Solution (Python):
s= input()

now = s[0]
ans = 0
flg = 0
for i in range(1,len(s)):
    if flg == 0:
        if now == s[i]:
            pass
        elif now != s[i]:
            ans += 1
            flg = 1
            now = s[i]

    else:
        if now == s[i]:
            pass
        elif now != s[i]:
            ans += 1
            flg = 0
            now = s[i]
            
print(ans)

Solution (Python):




from itertools import combinations,permutations 

from collections import deque,defaultdict











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

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
S = input()
cnt = 0
for i in range(len(S)):
    if i == 0:
        prv = S[i]
    else:
        if prv != S[i]:
            cnt += 1
            prv = S[i]
        else:
            pass
print(cnt)

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

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

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

Solution (Python):


import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

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

Solution (Python):
S = input().strip()
N = len(S)
cur = 0
cnt = 0
for i in range(1,N):
    if S[i]!=S[cur]:
        cnt += 1
        cur = i
print(cnt)

Solution (Python):
S = input()
b = S[0]
x = [b]
for s in S[1:]:
    if b == s: continue
    x.append(s)
    b = s
print(len(x)-1)

Solution (Python):
s = str(input())
temp = s[0]
X = []
cnt = 0
for i in range(len(s)):
    if s[i] == temp:
        cnt += 1
    else:
        temp = s[i]
        X.append(cnt)
        cnt = 1
else:
    X.append(cnt)
print(len(X)-1)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()


S = ins()


def solve():
    N = len(S)
    i = 0
    j = 1
    flip = 0
    while j < N:
        while j < N and S[i] == S[j]:
            j += 1
        if j == N:
            break
        flip += 1
        i = j
        j += 1

    return flip


print(solve())

Solution (Python):
import sys
input = sys.stdin.readline
from collections import *
from itertools import permutations

S = input()[:-1]
ans = 0

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

Solution (Python):
import re
s = input()
s = re.sub('[W]+', 'W', s)
s = re.sub('[B]+', 'B', s)
ans = len(s) - 1
print(ans)

Solution (Python):
def main():
    s = input()
    slen = len(s)
    cnt = 0
    last = 0
    if s[0] == "W":
        for i in range(slen-1):
            if s[i] == "W" and s[i+1] =="B":
                cnt += 1
        if s[-1] == "W":
            last = 1
    if s[0] == "B":
        for i in range(slen-1):
            if s[i] == "B" and s[i+1] =="W":
                cnt += 1
        if s[-1] == "B":
            last = 1        
    if cnt == 0:
        print(cnt)
    else:
        print(cnt*2 - 1 + last)
    

 
    
    
if __name__ == "__main__":
    main()

Solution (Python):
def BWstripper(S):
  BWarray=[]
  while (len(S) != 0):
    initial = S[0]
    tmp=""
    while (S[0] == initial):
      tmp+=S[0]
      S=S.lstrip(initial)
      if len(S) == 0:
        break
    BWarray.append(tmp)
  return BWarray
S=input()
stripped = BWstripper(S)
print(len(stripped)-1)

Solution (Python):
S = input()

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

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

Solution (Python):
s=input()
now,ans=0,0
while now<len(s)-1:
    if s[now]!=s[now+1]:
        ans+=1
    now+=1
print(ans)

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

ans = 0
B = S[0] == "B"

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

Solution (Python):
s = input()
n = len(s)
ans = -1
pre = ""

for i in s:
    if i != pre:
        ans += 1
    pre = i

print(ans)

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

Solution (Python):
import numpy as np
s = input()
ans = 0

for i in range(len(s)-1):
  if s[i] == s[i+1]:
    continue
  else:
    ans += 1
print(ans)

Solution (Python):
S=input()

now=S[0]

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

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

Solution (Python):

"""
Created on Thu Jun 11 17:09:47 2020

@author: sd18016
"""   

import sys
from itertools import groupby


S = list(input())

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


"""
for i in range(N):
    if list_x[i][2] == 1:
        de = list_x[i][0]
        S -= de*H
        W -= de
    elif list_x[i][2] == 2:
        de = W - list_x[i][0]
        S -= de*H
        W -= de
    elif list_x[i][2] == 3:
        de = list_x[i][1]
        S -= de*W
        H -= de
    else:
        de = H - list_x[i][1]
        S -= de*W
        H -= de

print(S)
"""

Solution (Python):
from sys import stdin
def main():
    
    readline=stdin.readline
    s=readline().strip()

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

    print(cnt-1)

if __name__=="__main__":
    main()

Solution (Python):
s = input()

c = 0
tmp = s[0]
for i in s:
    if i != tmp:
        c += 1
    tmp = i

print(c)

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

Solution (Python):
S = input()
count = 0
p = ''
for s in S:
  if s != p:
    p = s
    count += 1
print(count-1)

Solution (Python):
S = input()
if 'W' not in S:
    print(0)
elif 'B' not in S:
    print(0)
else:
    if S[0] == 'B':
        count = S.count('BW')
        if S[-1] == 'B':
            print(count*2)
        else:
            print(count*2 - 1)
    else:
        count = S.count('WB')
        if S[-1] == 'W':
            print(count*2)
        else:
            print(count*2 - 1)

Solution (Python):
s = input()

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

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

Solution (Python):
import sys

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


def resolve():
    s = input()
    n = len(s)
    res = 0
    for i in range(n - 1):
        if s[i] != s[i + 1]:
            res += 1
    print(res)


if __name__ == '__main__':
    resolve()

Solution (Python):

S = input()
cnt = 0
for i,c in enumerate(S):
    if i>0:
        if c!=S[i-1]:
            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):
import numpy as np
import sys
def sinput(): return sys.stdin.readline()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(): return list(imap())
def farr(): return list(fmap())
def sarr(): return sinput().split()

s = input()
ans = 1
tmp = s[0]
for i in s:
    if i != tmp:
        ans += 1
        tmp = i
print(ans-1)

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

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