Problem:


Score : 300 points

Problem Statement

There are N slimes lining up from left to right. The colors of these slimes will be given as a string S of length N consisting of lowercase English letters. The i-th slime from the left has the color that corresponds to the i-th character of S.

Adjacent slimes with the same color will fuse into one larger slime without changing the color. If there were a slime adjacent to this group of slimes before fusion, that slime is now adjacent to the new larger slime.

Ultimately, how many slimes will be there?

Constraints

1 \leq N \leq 10^5

|S| = N

S consists of lowercase English letters.

Input

Input is given from Standard Input in the following format:

N
S

Output

Print the final number of slimes.

Sample Input 1

10
aabbbbaaca

Sample Output 1

5

Ultimately, these slimes will fuse into abaca.

Sample Input 2

5
aaaaa

Sample Output 2

1

All the slimes will fuse into one.

Sample Input 3

20
xxzaffeeeeddfkkkkllq

Sample Output 3

10



Sample input:
10
aabbbbaaca


Sample output:
5

Submission status: Accepted

Solution code:
n = int(input())
s = input()
s_list = list(s)

tmp = s_list[0]
slime = [tmp]

for i in range(1,n):
    if tmp != s_list[i]:
        slime.append(s_list[i])
        tmp = s_list[i]
        
print(len(slime))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
n = int(input())
s = input()
gr = itertools.groupby(s)
print(len(list(gr)))

Submission status: Accepted

Solution code:
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
#pypyではscipy, numpyは使えない
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
#from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
import numpy as np
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial, log, log10, log2
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
from datetime import datetime as dt

def main():
  n = int(readline())
  s = input()
  last = ''
  ans = 0
  for i in range(n):
    if last != s[i]:
      last = s[i]
      ans += 1
  print(ans)
  
  
  
  
if __name__ == '__main__':
  main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())
S = input()
ans, i = 0, 0
while i < N:
  ans += 1
  while i + 1 < N and S[i + 1] == S[i]:
    i += 1
  i += 1
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
s=input()
t=s[0]
re=t
for ss in s:
    if t!=ss:
        re+=ss
        t=ss
print(len(re))

Submission status: Accepted

Solution code:
n = int(input())
s = input()
list1 = [s[0]]

for x in s:
  if x != list1[-1]:
    list1.append(x)
    
print(len(list1))

Submission status: Accepted

Solution code:
n = int(input())
s = list(input())
ans = s[0]

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

print(len(ans))

Submission status: Accepted

Solution code:
n = int(input())
s = input()

plev = ''
cnt = 0

for i in range(n):
    moji = s[i]
    if plev != moji:
        cnt += 1

    plev = s[i]

print(cnt)

Submission status: Accepted

Solution code:
def main():
    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
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    s = input().rstrip()
    res = 0
    for k,v in groupby(list(s)):
        res += 1
    print(res)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
s = input()
num = 1
for i in range(n - 1):
    if s[i] != s[i + 1]:
        num += 1
print(num)

Submission status: Accepted

Solution code:
n = int(input())
s = input()

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

Submission status: Accepted

Solution code:
N=int(input())
S=input()
print(1+sum(S[i]!=S[i-1] for i in range(1,N)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
s = input()

cnt = 1
dup = s[0]
for i in range(1, n):
    if dup != s[i]:
        dup = s[i]
        cnt += 1

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
S = input()
ans = [S[0]]
if len(S) == 1:
    print(1)
    exit()
for i in range(1,N):
    if S[i] == S[i-1]:
        continue
    else:
        ans.append(S[i])
print(len(ans))

Submission status: Accepted

Solution code:
N=int(input())
S=input()
ans=[S[0]]
if len(S)==1:
  print(1)
  exit()
for i in range(1,N):
  if S[i]==S[i-1]:
    continue
  elif S[i]!=S[i-1]:
    ans.append(S[i])
print(len(ans))

Submission status: Accepted

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

Submission status: Accepted

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

cnt = 0
ans = 0
for i in range(N-1):
    if(S[i] == S[i+1]):
        cnt += 1
        continue
    ans += 1
print(ans+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
s = input()
l = [s[0]]
for i in range(1,n):
    if s[i-1]!=s[i]:
        l.append(s[i])
print(len(l))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
s = input()

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

print(n-kieru)

Submission status: Accepted

Solution code:
#ABC143.C
N = int(input())
S = input()
cnt =0
for i in range(0,N-1):
    if S[i] == S[i+1]:
        cnt +=1
print(N-cnt)

Submission status: Accepted

Solution code:
N = int(input())
S = input()
ans = 1

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

print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from itertools import groupby
def main():
    N = int(input())
    S = input().rstrip("\r\n")
    print(len(list(groupby(S))))
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
s = list(input())
ans = 1
for i in range(1,n):
    if s[i] != s[i-1]:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N = int(input())
S = input()

cnt = 0
for i in range(N - 1):
    cnt += 1 if S[i] != S[i + 1] else 0

print(cnt + 1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
S = sr()
answer = 1
for x, y in zip(S, S[1:]):
    if x != y:
        answer += 1
print(answer)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

cnt = 1
now = S[0]
for s in S[1:]:
	if now == s:
		continue
	now = s
	cnt += 1

print(cnt)

Submission status: Accepted

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

print(n-p)

Submission status: Accepted

Solution code:
N = int(input())
S = input()
res = S[0]
for _ in range(1,len(S)):
    if res[-1] != S[_]:
        res = res + S[_]

print(len(res))

Submission status: Accepted

Solution code:
n = int(input())
s = input()
ans = len(s)

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
s=input()
count=1
for i in range(n-1):
  if (s[i]==s[i+1]):
    continue
  count+=1
  
print(count)

Submission status: Accepted

Solution code:
input()
s = input()

cnt = 0
pre = '0'
for c in s:
    if c != pre:
        cnt += 1
    pre = c
print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
S = input()
ans = ''
w = ''
for slime in S:
  if w=='':
    w = slime
    ans = slime
    continue
  if w!=slime:
    w = slime
    ans += slime
print(len(ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import groupby
N = int(input())
S = input()
G = groupby(S)
print(len(list(G)))

Submission status: Accepted

Solution code:
n=int(input())
S=input()
now="0"
ans=0
for s in S:
    if s!=now:
        ans+=1
    now=s
print(ans)

Submission status: Accepted

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

ans = list()
for i in S:
    try:
        if i != ans[-1]:
            ans.append(i)
    
    except:
        ans.append(i)

print(len(ans))

Submission status: Accepted

Solution code:
n=int(input())
str=input()
count=0
for i in range(n-1):
    if str[i]==str[i+1]:
        count+=1
print(n-count)

Submission status: Accepted

Solution code:
N = int(input())
S = list(input())
ans = N
for i in range(1,N):
  if S[i-1] == S[i]:
    ans -= 1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
S = list(input())

ans = 1

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

Submission status: Accepted

Solution code:
import itertools 

N = int(input())
S = list(input())

s = itertools.groupby(S)
ans = []
for key, group in s:
    ans.append(key)
print(len(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
S = input()
ans = 0
prev_s = "."
for s in S:
    if prev_s != s:
        ans += 1
    prev_s = s
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
S = list(input())

prev = S[0]
ans = ''
ans += prev
for si in S[1:]:
    if si != prev:
        ans += si
        prev = si

print(len(ans))

Submission status: Accepted

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

pt,pt_c,pt_tmp,ans = 1,S[0],0,1
while pt < N:
    if S[pt] != S[pt_tmp]:
        pt_c = S[pt]
        pt_tmp = pt
        ans += 1
    pt += 1

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
s = list(input())
ans = s[0]

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

print(len(ans))

Submission status: Accepted

Solution code:
n = int(input())
s = list(input())
for i in range(n-1):
   if s[i] == s[i+1]:
      n = n-1
print(n)

Submission status: Accepted

Solution code:
import itertools
N=int(input())
S=input()
print(len(list(itertools.groupby(S))))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
s = input()
l = list(s)


ans = 1

for i in range(n - 1):
    if l[i] == l[i + 1]:
        continue
    else:
        ans += 1

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def solver():
    n = int(input())
    S = list(input())

    current = ''
    cnt = 0
    for s in S:
        if current != s:
            cnt = cnt + 1
            # print(s, cnt)
        current = s
    print(cnt)

if __name__ == '__main__':
    solver()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())
s = input()
flg = 0
res = 1
for i in range(n-1):
  if flg == 0 and s[i] == s[i+1]:
    flg = 1
  elif flg == 1 and s[i] == s[i+1]:
    pass
  else:
    flg = 0
    res += 1
print(res)

Submission status: Accepted

Solution code:
from  itertools import groupby
_ = input()
s = list(groupby(input()))

print(len(s))

Submission status: Accepted

Solution code:
n = int(input())
s = input()
cnt = 1
for i in range(n-1):
  if s[i] == s[i+1]:
    pass
  else:
    cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

N = int(input())
S = input().strip()

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

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
s=input()

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

print(c)

Submission status: Accepted

Solution code:
N = int(input())
S=list(input())
x = S[0]
ans = 1
for i in range(1, N):
    if x != S[i]:
        ans += 1 
    x = S[i]
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
s=input()

ans=1

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

Submission status: Accepted

Solution code:
import sys

n=int(sys.stdin.readline())
s=sys.stdin.readline()

num=0

for color in s:
    if num==0:
        pre=color
        num=1
    elif color==pre:
        continue
    else:
        num+=1
        pre=color
print(num-1)

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline

N = int(input())
S = input().strip()

now = S[0]
sub = 0
for i in range(1, N):
    new = S[i]
    if new == now:
        sub += 1
    else:
        now = new
print(N - sub)

Submission status: Accepted

Solution code:
n = int(input())
a = input()
ans = 0
t = ''
for i in a:
    if i != t:
        ans += 1
    t = i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
S = str(input())

res = 0
str_ch = []

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

print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
color = list(str(input()))

for i in range(N-1):
  if color[i] == color[i+1]:
    color[i] = 0

color_uni = [x for x in color if x != 0]
print(len(color_uni))

Submission status: Accepted

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

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

print(res)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
l = list(input())
ans = 1
for i in range(n-1):
  if l[i] != l[i+1]:
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
S = input()
ans = 1
for i in range(1,N):
  if S[i-1] != S[i]: ans += 1
print(ans)

Submission status: Accepted

Solution code:
import re
input()
print(len(re.sub(r'(.)\1+', ":", input())))

Submission status: Accepted

Solution code:
n = int(input())
s = input()

tmp = ""
ans = ""
for i in s:
    if i != tmp:
        ans += i
    tmp = i
print(len(ans))

Submission status: Accepted

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

x = S[0]
ans = [x]
for i in S:
    if x == i:
        x = i
    else:
        ans.append(i)
        x = i

print(len(ans))

Submission status: Accepted

Solution code:
import sys
import math

from collections import defaultdict
from collections import deque
def load(vtype=int):
    return vtype(input().strip())
def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]
def exit():
    import sys
    sys.exit(0)
def perm_sub(li, used):
    if len(li) == len(used):
        return [deque()]
    k = []
    for i in range(len(li)):
        if i in used:
            continue
        used.add(i)
        sub_list = perm_sub(li, used)
        for sub in sub_list:
            sub.appendleft(li[i])
        k.extend(sub_list)
        used.discard(i)
    return k
def perm_li(li):
    return perm_sub(li, set())
def perm_n(n):
    return perm_sub(list(range(n)), set())
def join_i(li, sep=""):
    return sep.join([str(e) for e in li])
def li2n(li):
    n, base = 0, 1
    for i in range(len(li)-1, -1, -1):
        n += li[i] * base
        base *= 10
    return n
def sli2ili(li):
    return [int(s) for s in li] 
def prime_list(n):
    li = [i for i in range(2, n+1)]
    for i in range(len(li)):
        if li[i] >= int(math.sqrt(n)):
            break
        if li[i] == -1:
            continue
        for j in range(i+1, len(li)):
            if li[j] % li[i] == 0:
                li[j] = -1
    return [n for n in li if n != -1]
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while True:
        r = a % b
        if r == 0: return b
        a, b = b, r
def lcm(a, b):
    return int(a * b / gcd(a,b))
def all_subset(li):
    s = []
    n = len(li)
    for bit in range(0, (1<<(n+1))):
        ss = set()
        for i in range(0, n):
            if (bit & (1 << i)):
                ss.add(li[i])
        s.append(ss)
    return s
def factorization(n):
    arr = []
    temp = n
    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

n = load()
s = load(str)

pre = s[0]
result = 1

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

print(result)

Submission status: Accepted

Solution code:
N = int(input().rstrip())
S = list(input())

res = ''
tmp = ''
for n in range(N):
  if n == 0:
    tmp = S[0]
  elif tmp != S[n]:
    res = res + tmp
    tmp = S[n]

res = res +tmp

print(len(list(res)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

N = int(input().strip())
S = input().strip()
#-----

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

print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
S = list(input())
ans = 1
#print(S)
x = S.pop(0)
while(True):
    #print(S)
    if S==[]:break
    for i in range(len(S)):
        if S[0]==x:
            del S[0]
        else:
            x = S.pop(0)
            ans+=1
            break
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
s = input()
ans = 0
j = 0
for i in s:
    if i != j:
        ans += 1
    j = i
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
S = str(input())
ans = 1
for i in range(N-1):
    if(S[i] == S[i+1]):
        pass
    else:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    N=int(input())
    S=list(input())

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

    print(cnt)


resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
S = input()
l = [S[0]]

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

print(len(l))

Submission status: Accepted

Solution code:
def resolve():
    n = int(input())
    s = input()
    ansl = [s[0]]
    for i in range(1, n):
        if s[i] != s[i-1]:
            ansl.append(s[i])
    print(len(ansl))
resolve()

Submission status: Accepted

Solution code:
N = int(input())
S = list(input())

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

print(count)

Submission status: Accepted

Solution code:
n = int(input())
s = str(input())
a = 0
for i in range(n-1):
     if s[i] == s[i + 1]:
          a += 1
print(n-a)

Submission status: Accepted

Solution code:
#143_C
from itertools import groupby
n = int(input())
s = input()
print(len(list(groupby(s))))

Submission status: Accepted

Solution code:
from itertools import groupby
_ = input()
print(len(list(groupby(input()))))

Submission status: Accepted

Solution code:
n=int(input())
s=input()
new_s=[]
new_s.append(s[0])
for i in range(1,n):
    if s[i]!=s[i-1]:
        new_s.append(s[i])

print(len(new_s))

Submission status: Accepted

Solution code:
N = int(input())
s = str(input())
S = []
for j in s:
  S.append(j)
for i in range(len(S)-1):
  if S[i] == S[i+1]:
    S[i] = ''
    i -= 1
  else:
    pass
print(len(''.join(S)))

Submission status: Accepted

Solution code:
a = int(input())
b = input() 

c = 0
slimes = 1
for x in b[1:]:
  if x != b[c]:
    slimes += 1
  c += 1

print(slimes)

Submission status: Accepted

Solution code:
N = int(input())
S = input()
flag = S[0]
num = 1
for i in range(1,N):
    if(flag != S[i]):
        flag = S[i]
        num += 1

print(num)

Submission status: Accepted

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

Submission status: Accepted

Solution code:


def submit():
    n = int(input())
    s = input().strip()

    color_change = 1
    curr_color = s[0]
    for c in s[1:]:
        if curr_color != c:
            color_change += 1
            curr_color = c

    print(color_change)
    

if __name__ == "__main__":
    submit()

Submission status: Accepted

Solution code:
n = int(input())
s = input()

p = s[0]
x = s[0]
for i in range(1, n):
  if x == s[i]:
    continue
  else:
    p += s[i]
    x = s[i]

print(len(p))

Submission status: Accepted

Solution code:
from itertools import groupby

def solve():
    N = int(input())
    S = input()
    s = list(S)
    c = 0
    g = groupby(s)
    for k , v in g:
        c += 1

    return c

print(solve())

Submission status: Accepted

Solution code:

N = int(input())
S = input()

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

Submission status: Accepted

Solution code:
N = int(input())
S = input()
cnt = 1
for i in range(1,N):
    if(S[i] == S[i-1]):
        continue
    cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
import re
N = int(input())
ans = input()
charset = [chr(ord("a") + i) for i in range(26)]
for c in charset:
    ans = re.sub(r"{}+".format(c), c, ans)
print(len(ans))

Submission status: Accepted

Solution code:
N = int(input())
S = input()
count = 1
i = 0
while i < N - 1:
  if S[i] != S[i + 1]:
    count += 1
  i += 1  
print(count)

Submission status: Accepted

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

print(ans+1)

Submission status: Accepted

Solution code:
N=int(input())
S=input()
list=[S[i] for i in range(N)]
for i in range(N-1):
        if list[i]==list[i+1]:
            list[i]="0"
list=[s for s in list if s != '0']
print(len(list))

Submission status: Accepted

Solution code:
# import math
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque
# from collections import Counter

import numpy as np
# import scipy as scp

# 入力の受け取り
n = int(input())
s = input()

arrS = list(s)

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

print(ans)

Submission status: Accepted

Solution code:

N = int(input())
A = list(input())

count=1
dammy = A[0]

for i in range(1,N):
    if dammy != A[i]:
        count+=1
        dammy=A[i]
    else:
        continue
print(count)

Submission status: Accepted

Solution code:
#abc129 c
n=int(input())
s=input()
ans=["0"]
for c in s:
    if ans[-1]!=c:
        ans.append(c)
print(len(ans)-1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
s = input()
a = 1
for i in range(n-1):
    if s[i]!=s[i+1]:
        a+=1
print(a)

Submission status: Accepted

Solution code:
N=int(input())
S=list(input())

count=0
pre=""
for i in range(N):
  if S[i]!=pre:
    count+=1
  pre=S[i]
print(count)

Submission status: Accepted

Solution code:
n = int(input())
s = input()

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

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
s = input()

prev = ""
cnt = 0
for c in s:
    if prev != c:
        cnt += 1
        prev = c
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 10 21:19:58 2020

@author: Kanaru Sato
"""
n = int(input())
s = input()

slime = [s[0]]

if n > 1:
    for i in range(1,n):
        if slime[-1] != s[i]:
            slime.append(s[i])

print(len(slime))

Submission status: Accepted

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

ans = []
prev = S[0]
for i in range(1, N):
    if prev != S[i]:
        ans.append(prev)
        prev = S[i]
    else:
        pass
ans.append(prev)
print(len(ans))

Submission status: Accepted

Solution code:
n = int(input())
s = input()

total = len(s)

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

print(total)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    S = list(input())

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

    #print(result)
    print(len(result))



if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
S = list(input())
s = list(S[0])
for c in S[1:]:
    if not c == s[-1]:
        s.append(c)
print(len(s))

Submission status: Accepted

Solution code:
import math
n = int(input())
s = input()
count = 1
for i in range(n-1):
    if s[i] != s[i+1]:
        count += 1
print(count)

Submission status: Accepted

Solution code:
from collections import deque

N = int(input())
S = deque(list(input()))
count = 1
if len(S) == 1:
    print(1)
else:
    q = S.popleft()
    while (True):
        if q != S[0]:
            count += 1
        q = S.popleft()
        if len(S) == 0:
            break
    print(count)

Submission status: Accepted

Solution code:
n = int(input())
s = list(input())
count = 1
for i in range(n-1):
    if s[i+1] != s[i]:
        count += 1
print(count)

Submission status: Accepted

Solution code:
n = int(input())
ss = input()

ans = 1
s_before = ss[0]
for s in ss:
    if s != s_before:
        ans += 1
        s_before = s

print(ans)

Submission status: Accepted

Solution code:
def main():
    n=int(input())
    s=input()
    # l= list(map(int, input().split()))
    # s=sum(l)
    a=1
    for i in range(1,n):
        if s[i]!=s[i-1]:
            a+=1
    print(a)
    return
main()

Submission status: Accepted

Solution code:
n = int(input())
s = input()
count = n
for i in range(n-1):
  if s[i] == s[i+1]:
    count -= 1
print(count)

Submission status: Accepted

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

cnt = 0
c = ""
for s in S:
    if c != s:
        cnt += 1
    c = s
print(cnt)

Submission status: Accepted

Solution code:
n=int(input())
s=input()
count=0
for i in range(n-1):
    if s[i]==s[i+1]:
        count+=1
print(n-count)

Submission status: Accepted

Solution code:
n=int(input())
S=input()
ans=0
chk=''
for s in S:
    if chk==s:
        s = ''
    else:
        ans += 1
        chk = s
print(ans)

Submission status: Accepted

Solution code:
f=input;n,s=int(f()),f()
print(1+sum(s[i]!=s[i-1] for i in range(1,n)))

Submission status: Accepted

Solution code:
f=input;n=int(f());s=f()
print(1+sum(s[i]!=s[i-1] for i in range(1,n)))

Submission status: Accepted

Solution code:
f=input;f()
import itertools as it
print(len(list(it.groupby(f()))))

Submission status: Accepted

Solution code:
f=input;f();s=f()
import itertools as it
print(len(list(it.groupby(s))))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
S=input()
for i in range(1,len(S)):
  if S[i]==S[i-1]:
    N-=1
print(N)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

n = int(input())
s = list(input())

memo = ""
c = 0

for i in range(n):
    if s[i] == memo:
        continue
    else:
        memo = s[i]
        c += 1

print(c)

Submission status: Accepted

Solution code:
num = int(input())
s = input()
pre_s = s[0]
count = 1

for c in s:
    if(pre_s!=c) :
        count+=1
        pre_s=c

print(count)

Submission status: Accepted

Solution code:
N = int(input())
S = input()
Num = 1
s = S[0]
for i in range(1,N):
  c = S[i]
  if s==c:
    continue
  else:
    Num+=1
    s=c
print(Num)

Submission status: Accepted

Solution code:
N = int(input())
S = list(input())
out = ""
for x in range(N):
    if x == 0 or S[x] != S[x-1]:
        out += S[x]

print(len(out))

Submission status: Accepted

Solution code:
N=int(input())
S=input()
count=0
for i in range(N-1):
    if S[i]==S[i+1]:
        count+=1

print(N-count)