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

Submission status: Accepted

Solution code:
S = list(input())
runlength = []
temp = S[0]
if len(set(S)) == 1:
    print(0)
    exit() 
for i in range(1,len(S)):
    if temp != S[i]:
        runlength.append(temp)
        temp = S[i]
runlength.append(temp)
print(len(runlength)-1)

Submission status: Accepted

Solution code:
# ABC047 C 一次元リバーシ

import itertools

s = itertools.groupby(list(input()))

ans = 0
for _ in s:
    ans += 1

print(ans - 1)

Submission status: Accepted

Solution code:
def main():
    S  = input()
    A = S[0]

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

    print(len(A)-1)



if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

before_char = S[0]
ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
import re
import math
from collections import defaultdict
from collections import deque
import collections
from fractions import Fraction
import itertools
from copy import deepcopy
import random
import time
import os
import queue
import sys
import datetime
from functools import lru_cache
#@lru_cache(maxsize=None)
readline=sys.stdin.readline
sys.setrecursionlimit(2000000)
#import numpy as np
alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(n)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def ispow(a,b):#aはbの累乗数か
    now=b
    while now<a:
        now*=b
    if now==a:return True
    else:return False
def getbin(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def getfacs(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod_>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def nextcomb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:return num
def getprimes(n,type="int"):
    if n==0:
        if type=="int":return []
        else:return [False]
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def isprime(num):
    if(num<=1):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(a,b,c):
    if a:return b
    else:return  c
def join(A,c=""):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
def factorize(n,type_="dict"):
    b = 2
    list_ = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            list_.append(b)
        b+=1
    if n > 1:list_.append(n)
    if type_=="dict":
        dic={}
        for a in list_:
            if a in dic:
                dic[a]+=1
            else:
                dic[a]=1
        return dic
    elif type_=="list":
        return list_
    else:
        return None
def pm(x):
    return x//abs(x)
def inputintlist():
    return list(map(int,input().split()))
######################################################################################################

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

Submission status: Accepted

Solution code:
s = input()
a = s[0]
c = 0
for i in range(len(s)):
  if a == s[i]:
    pass
  else:
    c += 1
    a = s[i]
print(c)

Submission status: Accepted

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

Submission status: Accepted

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

import sys
# import time
# import math
# import numpy as np
# import scipy.sparse.csgraph as cs            # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall
# import random                                # random, uniform, randint, randrange, shuffle, sample
# import string                                # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from datetime import date, datetime          # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj
# from datetime.datetime import strptime       # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj
# from datetime import timedelta               # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available.
# from copy import copy, deepcopy              # use deepcopy to copy multi-dimentional matrix without reference
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)



def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1             # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    board = input()
    n = len(board)
    cnt = 0
    for i in range(n-1):
        if board[i] != board[i+1]:
            cnt += 1
    print(cnt)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a=input()
ans=0
for i in range(0,len(a)-1):
    if a[i]!=a[i+1]:
        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:
#!/usr/bin/env python3

import re
S = input()
S = re.sub("W+", "W", S)
S = re.sub("B+", "B", S)
print(len(S) - 1)

Submission status: Accepted

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

if count==0 : print(0)
else : print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

S = sys.stdin.readline().strip()
changed = 0
for i in range(len(S) - 1):
    if S[i] != S[i+1]:
        changed += 1

print(changed)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def cin():
	return map(int,input().split())

def cino(test=False):
    if not test:
        return int(input())
    else:
        return input()
def cina():
  return list(map(int,input().split()))


s = cino(True)
s+='A'
s = list(s)
cnt = -1
for i in range(len(s)-1):
    if s[i+1]!=s[i]:
        cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Thu May 14 18:16:23 2020

@author: shinba
"""

s = input()

start = s[0]
cnt1 = 0

for i in range(1,len(s)):
    if s[i] == start:
        continue
    cnt1 += 1
    start = s[i]

start = s[-1]
cnt2 = 0

for i in range(len(s)-1,-1,-1):
    if s[i] == start:
        continue
    cnt2 += 1
    start = s[i]

print(min(cnt1,cnt2))

Submission status: Accepted

Solution code:
def main():
    from itertools import groupby
    s = input()
    c = 0
    for k, g in groupby(s):
        c += 1

    print(c - 1)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

def solve():
    S = list(input())

    obj = S[0]
    cnt = 1
    L = []
    for i in range(1, len(S)):
        if S[i] == obj:
            cnt += 1
        else:
            L.append(cnt)
            obj = S[i]
            cnt = 1
    L.append(cnt)

    # print(L)
    print(len(L) - 1)


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal

sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===
def main():
    s = list(sys.stdin.readline())
    del s[len(s) - 1]
    cnt = 0

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

    print(max(0, cnt))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = input()

print(len([0 for c1, c2 in zip(S[:-1], S[1:]) if c1 != c2]))

Submission status: Accepted

Solution code:
S = input()

print(len([0 for index, c in enumerate(S[1:], 1) if c != S[index - 1]]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = 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:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()

now = ""
count = 0

for stone in S:
	if stone != now:
		count += 1
	now = stone
print(count-1)

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

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

Submission status: Accepted

Solution code:
s = input()

ans = 0
tmp = s[0]
for x in s[1:]:
    if x != tmp:
        ans += 1
        tmp = x

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections
import numpy as np
import sys
import copy
from functools import lru_cache
sys.setrecursionlimit(10**8)
#N,K=map(int,input().split())
#N=int(input())
#h=np.array(list(map(int,input().split())))
#ans=0
num2alpha = lambda c: chr(c+96)
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:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9+7

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 = list(input())
if len(list(set(S))) != 1:
    i =0
    count = 0
    while True:
        if S[i] != S[i+1]:
            count += 1
            S[i] = S[i + 1]
        i += 1
        if i == (len(S)-1):
            break
else:
    count = 0
print(count)

Submission status: Accepted

Solution code:
S = input()

def countcomponents(S):
    count = 1
    current = S[0]
    for i in range(len(S)):
        if S[i] != current:
            count += 1
            current = S[i]
    return count

print(countcomponents(S) - 1)

Submission status: Accepted

Solution code:
s = list(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())
cnt = 1
ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
from itertools import groupby


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

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

Submission status: Accepted

Solution code:
import sys
import os
import math
import bisect
import collections
import itertools
import heapq

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    S = list(iss())
    q = S[0]
    ret = 0
    for s in S:
        if q != s:
            ret += 1
            q = s
    print(ret)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
import os
import math
import bisect
import collections
import itertools
import heapq

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    S = itertools.groupby(list(iss()))
    q = ''
    ret = 0
    for s in S:
        if q == '':
            q = s
        if q != s:
            ret += 1
            q = s
    print(ret)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(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:
S = list(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:
def resolve():
	s = input()
	k = 0
	for i in range(len(s)-1):
		if s[i] != s[i+1]:
			k += 1
	print(k)
resolve()

Submission status: Accepted

Solution code:
S = input()
c = 0
if set(S) == 0:
    print(0)
else:
    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())

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()
c1=s[0]
res=0
for c in s:
    if c==c1:
        continue
    else:
        res+=1
        c1=c
print(res)

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:
def main():
    S = input()
    answer = 0

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

    print(answer)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = input()
ex = s[0]
count = 0
for c in s:
  if c!= ex:
    count +=1
    ex = c
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:
import itertools
S = input()
G = itertools.groupby(S)
print(len(list(G))-1)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
s = input()
prev = None
total = 0
for i in s:
    if prev == None:
        prev = i
    else:
        if (i != prev):
            total += 1
            prev = i
        else:
            pass
print(total)

Submission status: Accepted

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

Submission status: Accepted

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



if '__main__' == __name__:
    resolve()

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

Submission status: Accepted

Solution code:
S = input()
ans = -1
old = ""
for c in S:
  if old != c:
    old = c
    ans += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = input()
ans = 0
pre = S[0]
for s in S:
  if pre != s:
    ans += 1
  pre = s

print(ans)

Submission status: Accepted

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

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:
from itertools import groupby
s = input()
print(len(list(groupby(s)))-1)

Submission status: Accepted

Solution code:
import re

s = input()
s = re.sub(r'W+', "W", s)
s = re.sub(r'B+', "B", s)
print(len(s) - 1)

Submission status: Accepted

Solution code:
s = input()
li_s = list(s)
start = li_s[0]
count=0
for l in li_s:
    if l!=start:
        count+=1
        start = l
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:
l = input()

print(l.count('WB') + l.count('BW'))

Submission status: Accepted

Solution code:
s=input()
from itertools import groupby as gb
print(len(list(gb(s)))-1)

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

print(S.count("BW") + S.count("WB"))

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

s = read().rstrip().decode()
memo = s[0]
cnt = 0
for check in s[1:]:
    if memo != check:
        memo = check
        cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
s = input()
t = ""
count = -1

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

Solution code:
s = input()
ans = 0
color = s[0]
for i in range(1, len(s)):
    if color != s[i]:
       color = s[i]
       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:
#Beginner 047 C
S = str(input())
res = 0

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

print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

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:
import sys
readline = sys.stdin.readline

def main():
    S = list(readline().rstrip())
    ans = 0
    for i in range(1, len(S)):
        if S[i-1] != S[i]:
            ans += 1
    
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = input()
t = s[0]
res = 0
if len(s)==1:
    print(0)
    exit()
for i in s[1:]:
    if t == i:
        pass
    else:
       res = res+1
       t = i

print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
current = None
cnt = 0
for i in S:
    if i != current:
        current = i
        cnt += 1
print(cnt - 1)

Submission status: Accepted

Solution code:
S = str(input())

l = len(S)
count = 0

if S[0]=='W':
	isblue = 0
else:
	isblue = 1


for i in range (1, l):
	if isblue == 0 and S[i] == 'B':
		isblue = 1
		count+=1
	elif isblue == 1 and S[i] == 'W':
		isblue = 0
		count+=1
	else:
		continue

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input() + 'x'

c = 'x'
cnt = 0
for s in S:
    cnt += (s != c)
    c = s
print(cnt - 2)

Submission status: Accepted

Solution code:
s=list(input())

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