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())
word = input()
answer = 0
for i in range(n-1):
    if word[i] != word[i+1]:
        answer += 1
print(answer+1)

Submission status: Accepted

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

judge = [1]*N

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

print(sum(judge))

Submission status: Accepted

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

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

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


ans = 0
pre = None
for s in S:
    ans += (pre != s)
    pre = s
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

K=0
A="*"
for s in S:
    if s!=A:
        A=s
        K+=1
print(K)

Submission status: Accepted

Solution code:
N = int(input())
S = input()
ans = 0
prev = -1
for s in S:
  if prev != s:
    ans+=1
    prev=s
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:
N = int(input())
S = str(input())
cnt = 1

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

print(cnt)

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify

import itertools
import math, fractions
import sys, copy

def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def SL(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def R(n): return [sys.stdin.readline().strip() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SR(n): return [SL() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]

def perm(n, r): return math.factorial(n) // math.factorial(r)
def comb(n, r): return math.factorial(n) // (math.factorial(r) * math.factorial(n-r))

def make_list(n, *args, default=0): return [make_list(*args, default=default) for _ in range(n)] if len(args) > 0 else [default for _ in range(n)]

dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
alphabets = "abcdefghijklmnopqrstuvwxyz"
ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
MOD = 1000000007
INF = float("inf")

sys.setrecursionlimit(1000000)

def main():
    N = I()
    S = SL()

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


if __name__ == '__main__':
    main()

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()
ans=1
mark=s[0]
for a in s:
    if a!=mark:
        mark=a
        ans+=1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
S = input()
S = [i for i in S]

cnt = 1
Cnt = []

for i in range(1, N):
    if S[i]==S[i-1]:
        cnt += 1
    elif S[i]!=S[i-1]:
        Cnt.append(cnt)
        cnt = 1
Cnt.append(cnt)
print(len(Cnt))

Submission status: Accepted

Solution code:

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    cnt=0
    N=I()
    S=input()
    now="A"
    for i in range(N):
        if S[i]!=now:
            cnt+=1
        now=S[i]
        
    print(cnt)

main()

Submission status: Accepted

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

    cnt = 1

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

    print(cnt)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys

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


def main():
    from itertools import groupby

    N = int(readline())
    S = input()
    ans = 0
    for g in groupby(S):
        ans += 1

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())
a=input()
s=list(a)
b=list(a)
j=0
for i in range(0,n-1):
    if s[i]==s[i+1]:
        b.pop(i-j)
        j=j+1
    else:
        pass
print(len(b))

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 問題：https://atcoder.jp/contests/abc143/tasks/abc143_c

n = int(input())
slimes = input()
res = 1
for i in range(1, n):
    if slimes[i-1] != slimes[i]:
        res += 1
print(res)

Submission status: Accepted

Solution code:
n=int(input())
s=input()
k=0
l=set(s)
k=s[0]
ans=1
if len(l)==1:
    print("1")
    exit()
for i in range(1,n):
    if k!=s[i]:
        ans+=1
        k=s[i]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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:
a = int(input())
b = input()
c = 1
for i in range(a-1):
  if b[i] != b[i+1]:
    c += 1
print(c)

Submission status: Accepted

Solution code:
n = int(input())
s = str(input())
s += "A"
q = s[0]
ans = 0
for i in range(n+1):
  if(q==s[i]):
    None
  else:
    ans += 1
    q = s[i]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
s = input()
S = []
for i in s:
    S.append(i)
from collections import deque
q = deque(S)
ans = []
while q:
    c  =q.popleft()
    if not ans:
        ans.append(c)
    else:
        while ans and ans[-1]==c:
            ans.pop()
        ans.append(c)

print(len(ans))

Submission status: Accepted

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

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

cnt = 0
sum = len(S)


for i in range(N-1):

  
  if S[i] == S[i+1]:
  	cnt += 1
  else:
  	continue

ans = sum - cnt

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

S = input()

ans = []

for i in range(N):
    p = S[i]

    if i != N - 1:
        if p != S[i+1]:
            ans.append(S[i])
        else:
            continue
    else:
        ans.append(S[i])

print(len(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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 itertools import groupby
N = int(input())
S = input()
gr = list(groupby(S))
print(len(gr))

Submission status: Accepted

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

    temp = S[0]
    result = 1
    for i in range(1,N):
        if temp != S[i]:
            result += 1
            temp = S[i]

    print(result)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

for i in reversed(range(1,n)):
    if s[i-1]==s[i]:
        s.pop(i)

print(len(s))

Submission status: Accepted

Solution code:
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq

n = ni()
s = input()
cnt = 0
prev=""
for i in range(n):
    if prev==s[i]:
        pass
    else:
        cnt+=1
    prev=s[i]
print(cnt)

Submission status: Accepted

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

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

print(cnt)

Submission status: Accepted

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

x = d[0]
count = 1
for i in d:
    if i != x:
        count += 1
        x = i
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N=ii()
    S=list(input())

    pre = None
    X = []
    for s in S:
        if s != pre:
            X.append(s)

        pre = s
    
    print(len(X))






if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
from itertools import groupby
n = int(input())
s = input()

gr = groupby(s)
ans = 0
for key, value in gr:
    ans += 1

print(ans)

Submission status: Accepted

Solution code:
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
n=int(input())
s=input()
ans=n
for i in range(1,n):
    if s[i]==s[i-1]:
        ans-=1
print(ans)

Submission status: Accepted

Solution code:
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
# from collections import Counter,defaultdict,deque
# from itertools import permutations, combinations
# from heapq import heappop, heappush
# # input = sys.stdin.readline
# sys.setrecursionlimit(10**8)
# mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n = inp()
s = input()
pre = ''
ans = 0
for t in s:
    if(pre != t):
        ans += 1
    pre = t
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
sList = list(input())
count = 0
tmp = ''
for s in sList:
    if(s != tmp):
        count += 1
        tmp = s

print (count)

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

Submission status: Accepted

Solution code:
N = int(input())
S = input()
anchor = ''
ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
a = int(input())
s = input()
ans = ''
for i in range(a-1):
    if s[i] == s[i+1]:
        continue
    else:
        ans += s[i]
ans += s[-1]
#print(ans)
print(len(ans))

Submission status: Accepted

Solution code:
n = input()
s = input()
# n：スライムの数
# s：スライムの色情報

# 最終的に存在するスライムの数を答える
judge_str = s[0]
ans=1
for i in s:
    if i != judge_str:
        ans+=1
        judge_str = i
print(ans)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    s = input()
    ans = 1
    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:
n=int(input())
s=input()
ans=0

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

print(ans)

Submission status: Accepted

Solution code:
N=int(input())
S = input()
List = list(S)
resList = [S[0]]
for i in range(1,N):
  if List[i] == List[i-1]:
    pass
  else:
    resList.append(List[i])
print(len(resList))

Submission status: Accepted

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

print(len(fused))

Submission status: Accepted

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

d = []
for n in range(1, N):
    if S[n-1] == S[n]:
        d.append(n)

cnt = 0
for i in d:
    i -= cnt
    del S[i]
    cnt += 1
    
print(len(S))

Submission status: Accepted

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

ans = []
for i in range(len(S)):
    if i == len(S) - 1:
        ans.append(S[i])
        break
    if S[i] != S[i+1]:
        ans.append(S[i])
print(len(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:
n = int(input())
s = input()
memo = ""
for i in s:
  if memo == i:
    n-=1
  else:
    memo=i
print(n)

Submission status: Accepted

Solution code:
n = int(input())
s = input()
prev = ""
ans = ""
for i in range(n):
    if s[i] == prev:
        continue
    prev = s[i]
    ans += s[i]
print(len(ans))

Submission status: Accepted

Solution code:
N = int(input())
S = str(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())
S = input()
A = ['']
for i in S:
    if i != A[-1]:
        A.append(i)
print(len(''.join(A)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

n = int(input())

s = input()

ans = 1
tmp = s[0]

for c in s:
    if tmp != c:
        ans += 1
        tmp = c

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

cnt = 1
col = S[0]

for c in S:
    if(c != col):
        cnt += 1
        col = c

print(cnt)

Submission status: Accepted

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

ans=1
tmp=S[0]

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

    
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:
n=int(input())
a=input()
c=[]
pre=''
for x in a:
  if x!=pre:
    c.append(x)
  pre=x
print(len(c))

Submission status: Accepted

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

res = 1
tmp = S[0]
for i in range(1,n):
  if S[i] != tmp:
    res += 1
  tmp = S[i]
print(res)

Submission status: Accepted

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

Submission status: Accepted

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

i = 0
count = 0
while i < n:
  c = s[i]
  while i < n and s[i] == c:
    i += 1
  count += 1
print(count)

Submission status: Accepted

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

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

print(t)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
s=list(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 math
from collections import defaultdict,deque
#from itertools import permutations
ml=lambda:map(int,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:list(input())
ips=lambda:input().split()

"""========main code==============="""

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

Submission status: Accepted

Solution code:
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
import itertools
from collections import Counter

def main():
    n = int(input())
    s = input().rstrip()
    ans = [s[0]]
    now = s[0]
    for i in s[1:]:
        if i != now:
            ans.append(i)
            now = i
    print(len(ans))

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

Submission status: Accepted

Solution code:
import itertools as i;N = int(input());print(len([k for k, v in i.groupby(input())]))

Submission status: Accepted

Solution code:
import itertools;N = int(input());print(len([k for k, v in itertools.groupby(input())]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
input()
S=input()

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

Submission status: Accepted

Solution code:
input()
S=input()

while True:
 x=''
 ans=''
 for i in S:
   if (x==''):
    x=i
    continue
   if x!=i:
    ans+=x
    x=i
 ans+=x
 if ans==S:
   break
 else:
   S=ans
print(len(ans))

Submission status: Accepted

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

while True:
    x=''
    ans=''
    for i in S:
       if (x==''):
        x=i
        continue
       if x!=i:
        #print("p:",x,i,ans)
        ans+=x
        x=i
        #print("a:",x,i,ans)

    ans+=x
    #print('ans:',ans)
    if ans==S:
        break
    else:
        S=ans
print(len(ans))

Submission status: Accepted

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

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:
#https://atcoder.jp/contests/abc143/tasks/abc143_c
N =int(input())
S =str(input())
cnt = 1
moji = S[0]
for i in range(1,N):
    if S[i] != moji:
        cnt += 1
        moji = S[i]

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()
res = 0

f = S[0]

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

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]:
        cnt += 1
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())
S = input()
ls = [S[0]]
for s in S[1:]:
    if ls[-1] == s:
        continue
    ls.append(s)
print(len(ls))

Submission status: Accepted

Solution code:
N = int(input())
S = input().rstrip()
res = 1
s0 = S[0]
for s in S[1:]:
    if s != s0:
        res += 1
    s0 = s
print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instr = lambda: sys.stdin.readline()
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n = inint()
s = instr()

prev = s[0]
ans = 1

for i in range(1,n):
    if s[i] == prev:
        continue
    else:
        prev = s[i]
        ans += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
s = input()
prv = "*"
ans = 0
for i,c in enumerate(s):
    if c!=prv:
        ans += 1
    prv = c
print(ans)

Submission status: Accepted

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

a=0#色変化
for i in range(N-1):
    if not S[i]==S[i+1]:
        a=a+1
print(a+1)

Submission status: Accepted

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

def main():

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

    ans = 1

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

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

Submission status: Accepted

Solution code:
import sys
lines = [s.rstrip("\n") for s in sys.stdin.readlines()]
n = int(lines.pop(0))
s = lines.pop(0)
count = 0
prev_c = None
for c in s:
    if c != prev_c:
        count += 1
    prev_c = c
print(count)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import bisect,collections,copy,heapq,itertools,math,string
import numpy as np
import sys
sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
S = _S()
#Ap = np.array(A)
#C = np.zeros(N + 1)

last = ''
count = 0
for i in range(N):
    a = S[i]
    if not last == a:
        count += 1
        last = a
print(count)

Submission status: Accepted

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

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

print(len(s_new))

Submission status: Accepted

Solution code:


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


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


def solve():
    N = read_int()
    S = input()
    count = 1
    for i in range(1, N):
        if S[i] != S[i-1]:
            count += 1
    return count


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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

print(len(ans))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from sys import stdin,stdout
def INPUT():return list(int(i) for i in stdin.readline().split())
import math
def inp():return stdin.readline()
def out(x):return stdout.write(x)
import math as M
MOD=10**9+7
import sys
#####################################
n=int(input())
A=list(input())
X=["0"]
for i in range(n):
    if X[-1]!=A[i]:
        X.append(A[i])
X.pop(0)
print(len(X))