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

s0 = S[0]
for s in S[1:]:
    if s == s0:
        N -= 1
    else:
        s0 = s
print(N)

Submission status: Accepted

Solution code:
n = int(input())
s = input()
last = ''
c = 0

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

print(c)

Submission status: Accepted

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

prev = 0
answer = 0
for x in S:
    if x != prev:
        answer += 1
    prev =x
print(answer)

Submission status: Accepted

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

Submission status: Accepted

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

print(N - count)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 1
prec = S[0]
for c in S:
    if c != prec:
        ans += 1
    prec = c

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

i = 0
count = 0
while i < N-1:

    if S[i]==S[i+1]:
        i = (i+1)
        continue
    else:
        count = count + 1
    i = i + 1

print(count+1)

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 main():
    A = input()
    B = input()
    old = ''
    ans = 0
    for b in B:
        if b != old:
            ans += 1
            old = b
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

s = 1
pre = d[0]
for di in d[1:]:
    if di == pre:
        continue
    s += 1
    pre = di
print(s)

Submission status: Accepted

Solution code:
import sys

def main():
    N = int(input())
    S = list(input())
    ans = 1

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

    print(ans)

main()

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    S = input()
    f = S[0]
    count = 0

    for i in S:
        if i!=f:
            count+=1
        f = i

    print(count+1)


if __name__ == "__main__":
    main()

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 = str(input())
color = s[0]
cnt = 1
for i in range(n-1):
    if not color == s[i+1]:
        cnt += 1
        color = s[i+1]
print(cnt)

Submission status: Accepted

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

ret = 0
prev = "prev"
for s in S:
  if s != prev:
    ret += 1
    prev = s
    
print(ret)

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

p = ''
result = 0
for i in range(N):
    if p != S[i]:
        result += 1
        p = S[i]
print(result)

Submission status: Accepted

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

pre = S[0]
c = 1

for s in S[1:]:
    if not s == pre:
        c += 1
    pre = s

print(c)

Submission status: Accepted

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

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

print(len(ans))

Submission status: Accepted

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

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)

i = 0
while i < len(l) - 1:
    if l[i] != l[i + 1]:
        i += 1
        continue
    del l[i]

print(len(l))

Submission status: Accepted

Solution code:
N = int(input())
S = str(input())
ans = 1
_s = S[0]
for n in range(1,N):
    if _s != S[n]:
        ans+=1
    _s = S[n]
print(ans)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    S = input()
    top = S[0]
    ans = 1
    for s in S:
        if s != top:
            ans += 1
            top = s
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

color_length = []
c = 1

for i in range(n-1):
    
    if s[i] == s[i+1]:
        c += 1
    
    else:
        color_length.append(c)
        c = 1

color_length.append(c)

print(len(color_length))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from itertools import groupby
N = int(input())
S = list(input())
newS = list([list(g) for k, g in groupby(S)])
print(len(newS))

Submission status: Accepted

Solution code:
N = int(input())
S = list(input())
li = list()
for i in range(N):
    if i < N-1:
        if S[i] != S[i+1]:
            li.append(S[i])
    else:
        li.append(S[i])
print(len(li))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
s = input()
now = s[0]
ans = 1
for i in range(1,n):
    if s[i] == now:
        pass
    else:
        now = s[i]
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
s = list(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:
n = int(input())
A = input()
A += '0'
a = 0
for j in range(n):
    if A[j] != A[j+1]:
        a += 1
print(a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
a=input()
counter=1
startpt=0
i=1
l=len(a)
while(i<l):
    if(a[i]!=a[i-1]):
        counter+=1

    i+=1
print(counter)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

cnt = 1

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

Submission status: Accepted

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

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(cnt + 1)

Submission status: Accepted

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

count = 1

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

print(count)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

print(output+1)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def slime(string: str) -> int:
    prev = string[0]
    count = 1
    for s in string[1:]:
        if s != prev:
            count += 1
        prev = s
    return count


if __name__ == '__main__':
    N = int(input())
    S = input()
    result = slime(S)
    print(result)

Submission status: Accepted

Solution code:
input()
import itertools
print(len(list(itertools.groupby(input()))))

Submission status: Accepted

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

ans = 0
before = ""
for s in S:
    if before == s:
        continue
    else:
        ans += 1
        before = s
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
s = input()
count = 0
prev = ""
for i in range(0, n):
	if s[i] == prev:
		pass
	else:
		count += 1
		prev = s[i]
print(count)

Submission status: Accepted

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

p = s[0]
cnt = 1

for i in range(1, n):
    if p == s[i]:
        pass
    else:
        p = s[i]
        cnt += 1

print(cnt)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n=int(input())
s=input()
count=1
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())
result = [S[0]]
count = 1

for i in range(1, N):
    if S[i] != result[-1]:
        result.append(S[i])
        count = count + 1

print(count)

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()
count=1
for i in range(N-1):
    if not S[i]==S[i+1]:
        count+=1
print(count)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
s = input()

cnt = 0
i = 0
while i<n:
    j = i
    while j<n and s[i]==s[j]:
        j += 1
    i = j
    cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
from itertools import groupby
def resolve():
    n=int(input())
    g=groupby(input())
    print(len(tuple(g)))
resolve()

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())
ans=1
S=input()
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 = 1
for i in range(N-1):
    if S[i] == S[i+1]:
        continue
    else:
        ans += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
import math

def main():
    N = int(input())
    S = input()
    cnt = 1
    for i in range(1, N):
        if S[i] != S[i-1]:
            cnt += 1
    print(cnt)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())
ch=input()
a=ch[0]
x=n
for i in range(1,n):
    if a==ch[i]:
        x-=1
    a=ch[i]
print(x)

Submission status: Accepted

Solution code:
N = int(input())
S = list(str(input()))
tmp = ""
dup_count = 0
for i in S :
	if tmp == i :
		dup_count += 1
	tmp = i
print(N - dup_count)

Submission status: Accepted

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

count   = 0
tgt_chr = s[0]
for ii in range(1, N):
    if s[ii]==tgt_chr:
        continue
    else:
        count += 1
        tgt_chr = s[ii]
print(count+1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

lines = sys.stdin.readlines()
n = lines[0].rstrip()
s = lines[1].rstrip()

c = s[0]
r = 1
for cursor in s[1:]:
    if cursor == c:
        pass
    else:
        r += 1
        c = cursor

print(r)

Submission status: Accepted

Solution code:
n=int(input())
s=input()
ans=1
pre_c = s[0]
for c in s[1:]:
    if c != pre_c:
        ans += 1
        pre_c = c
print(ans)

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

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

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def main():
    N = I()
    s = S()
    c = ''
    cnt = 0
    for i in range(N):
        if c != s[i]:
            cnt += 1
        c = s[i]
    print(cnt)

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from __future__ import print_function

import sys
input = sys.stdin.readline

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# import math
# import string
# import fractions
# from fractions import Fraction
# from fractions import gcd

# def lcm(n,m):
#     return int(n*m/gcd(n,m))

# import re
# import array
# import copy
# import functools
# import operator

# import collections
# import itertools
# import bisect
# import heapq


# from heapq import heappush
# from heapq import heappop
# from heapq import heappushpop
# from heapq import heapify
# from heapq import heapreplace

# from queue import PriorityQueue as pq

# def reduce(p, q):
#     common = fractions.gcd(p, q)
#     return (p//common , q//common )
# # from itertools import accumulate
# # from collections import deque

# from operator import mul
# from functools import reduce

# def combinations_count(n, r):
#     r = min(r, n - r)
#     numer = reduce(mul, range(n, n - r, -1), 1)
#     denom = reduce(mul, range(1, r + 1), 1)
#     return numer // denom

# import random

def main():
    n = int(input().strip())
    S = input().strip()
    cnt=1
    for i in range(1,n):
        if (S[i]==S[i-1]):
            pass
        else:
            cnt+=1
    print(cnt)
    return

if __name__ == '__main__':
    main()
'''
find x_cnt

for given n (1<=n<=10**5) ,S (1<=|S|=N<=10**5, \forall i \in [0...(N-1)].a<=S[i]<=z)



(i.e.)
aaabbcdfgggxx
abcdfgx


'''

Submission status: Accepted

Solution code:
n = int(input())
s = input()
x = ''
l = 0
for c in s:
    if x != c:
        x = c
        l = l + 1
print(l)

Submission status: Accepted

Solution code:
def main():
	n = int(input())
	s = list(str(input()))
	# s.sort()
	ans = 1
	# print(s)
	for i in range(len(s)-1):
		if s[i] != s[i+1]:
			ans += 1
	print(ans)



if __name__ == '__main__':
	main()

Submission status: Accepted

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

res = []
x = '0'
for c in S:
    if c == x:
        continue
    else:
        res.append(c)
        x = c

print(len(res))

Submission status: Accepted

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

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

    if S1 != S2:
        ans += 1

print(ans)

Submission status: Accepted

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

total = 1

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

print(total)

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(N-1):
    while True:
        if S[i]==S[i+1]:
            S[i]=''
        else:
            break

print(len([i for i in S if i!='']))

Submission status: Accepted

Solution code:
n = int(input())
s = input()
res = 0
pre = ''
for c in s:
  if pre != c:
    pre = c
    res += 1
print(res)

Submission status: Accepted

Solution code:
n = int(input())

s = list(str(input()))

a=0
if n == 1:
    print(1)
else:
    for i in range(n-1):
        if s[i] == s[i+1]:
            a += 1
    print(n-a)

Submission status: Accepted

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


print(N - count)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

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

ans = 0
last = ""
for i in s:
    if i != last:
        ans += 1
        last = i

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
input()
S=input()
t=""
a=0
for s in S:
    if s!=t:
        a+=1
        t=s
print(a)

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 = ans + 1

print(ans+1)

Submission status: Accepted

Solution code:
n=int(input())
s=str(input())
ans=[]
ans.append(s[0])
cnt=0
for i in range(1,n):
  if ans[cnt]==s[i]:
    continue
  else:
    cnt+=1
    ans.append(s[i])
print(len(ans))

Submission status: Accepted

Solution code:
input()
lastc = ""
count = 0
for c in input():
    if lastc != c:
        lastc = c
        count += 1

print(count)

Submission status: Accepted

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

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

list_S = list(S)

new_list_S = [list_S[0]]
for i in range(1, len(list_S)):
    if list_S[i] != list_S[i - 1]:
        new_list_S.append(list_S[i])

print(len(new_list_S))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#ABC-143-C
N = int(input())
S = input()
ans_S = S[0]
char = S[0]

for i in range(1, N):
    if S[i] != char:
        ans_S = ans_S + S[i]
        char = S[i]
        
print(len(ans_S))

Submission status: Accepted

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

count = 0
while True:
    S = S.lstrip(S[0])
    count = count + 1
    if len(S) == 0:
        break

print(count)

Submission status: Accepted

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

    merged = []
    previous = ""
    for i in S:
        if i != previous:
            merged.append(i)
        previous = i

    print(len(merged))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
while True:
    n = input()
    s = input()
    n = int(n)
    if(n==len(s)):
         break
    else:
        print("error")

d  = ''

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

d += s[len(s)-1]
print(len(d))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
i = input()
ls = list(input())

ans = []

base = ""
for s in ls:
    if (s != base):
        ans.append(s)
        base = s

print(len(ans))

Submission status: Accepted

Solution code:
N=int(input())
s=input()
a0=0
num=0
for i in range(0,N):
    a1=s[i]
    if a0==a1:
        a0=a1
    else:
        a0=a1
        num=num+1
print(num)

Submission status: Accepted

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

def main():
    input()
    print(len(tuple(itertools.groupby(input().rstrip()))))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
import itertools

def main():
    input()
    print(len(tuple(itertools.groupby(input()))))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    s = str(readline().rstrip().decode('utf-8'))
    cnt = 0
    for i in range(1, n):
        if s[i] != s[i-1]:
            cnt += 1
    print(cnt + 1)


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

for i, s in enumerate(S):
    if i == 0:
        slime = s
        continue
    if slime != s:
        c += 1
        slime = s

print(c+1)

Submission status: Accepted

Solution code:
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
n=int(input())
s=input()

cnt=0

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

Submission status: Accepted

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


def solve(N: int, S: str):
    lists = list(S)
    sample = ""
    for item in lists:
        if len(sample) == 0:
            sample += item
        elif sample[-1] != item:
            sample += item
    print(len(sample))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

f_sl = 1
for i in range(1, N):
    if sl[i] == sl[i-1]:
        continue
    else:
        f_sl += 1

print(f_sl)

Submission status: Accepted

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

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

l = [i for i in s if i != 0]

print(len(l))

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

Submission status: Accepted

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

N = int(input())
s = 1
S = list(input())
for i in range(N-1):
    if S[i+1] != S[i]:
        s += 1
    else:
        continue
print(s)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
S = input()
#A,B= map(int,input().split())
#S =list(map(int,input().split()))
# [list(map(int,input().split())) for i in range(N)]
color = "ab"
ans = 0
for i in range(N):
    if S[i]!=color:
        color = S[i]
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
s=input()
ans=1
if(n==1):
  print(1)
else:
  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

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

Submission status: Accepted

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

cnt = 1
for i, c in enumerate(s[:-1]):
    if c == s[i+1]:
        continue
    cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
import itertools

_ = input()
s = input()

r = 0
for v in itertools.groupby(s):
    r += 1

print(r)

Submission status: Accepted

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

tmp = n

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

print(tmp)

Submission status: Accepted

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

S = list(S)

i = 0
try:
    while i < N:
        if S[i] == S[i + 1]:
            S.pop(i+1)
        else:
            i += 1
except IndexError:
    pass

print(len(S))

Submission status: Accepted

Solution code:
N=int(input().strip())
S=input().strip()
tmp=S[0]
counter=1
for s in S:
    if s==tmp:
        continue
    else:
        counter+=1
        tmp=s
print(counter)

Submission status: Accepted

Solution code:
N = int(input())
S = input()
now_character = None
ans = 0
for i in range(N):
    if now_character == S[i]:
        pass
    else:
        now_character = S[i]
        ans+=1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
S = input()
S = list(S)
resultList = []
tmp = '-1'
for i in range(0, N):
    if tmp != S[i]:
        resultList.append(S[i])
        tmp = S[i]
    else:
        continue

print(len(resultList))

Submission status: Accepted

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

i = 0
while i<len(s)-1:
  if s[i] == s[i+1]:
    del s[i]
  else:
    i += 1
print(len(s))

Submission status: Accepted

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

print(count)

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:
input()
S = input()
runlength = []
begin, end = 0, 0
for i in range(len(S) - 1):
    if S[i] != S[i + 1]:
        end = i + 1
        runlength.append(S[begin:end])
        begin = i + 1
runlength.append(S[begin : len(S)])
print(len(runlength))

Submission status: Accepted

Solution code:
N = int(input())
S = input()
s = []
count = N
for line in S:
    s.append(line)
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=list(input())
L=[]
bef="A"
for i in range(n):
    if s[i]!=bef:
        L.append(s[i])
    bef=s[i]
print(len(L))

Submission status: Accepted

Solution code:
#ABC143-C Slimes
N = int(input())
S = list(input())
ans = 1
for i in range(N-1):
    ans += 1 if S[i] != S[i+1] else 0
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:
# -*- coding: utf-8 -*-

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

num_of_slimes = 1
color_of_left = S[0]

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

print(num_of_slimes)

Submission status: Accepted

Solution code:
from itertools import groupby

N = input()
S = input()

print(len(list(groupby(S))))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve(s: str) -> int:
  ret = 0
  cur_c = None
  for c in s:
    if c != cur_c:
      ret += 1
      cur_c = c
  return ret


n = int(input().strip())
s = input().strip()

print(solve(s))

Submission status: Accepted

Solution code:
n = int(input())
s = input()
 
before = 'aaa'
ans = 0
for char in s:
  if char != before:
    before = char
    ans += 1
print(ans)