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 = list(input())
cur = s[0]
ans = 1
for i in range(1, n):
    if s[i] == cur:
        next
    else:
        ans += 1
        cur = s[i]

print(ans)

Submission status: Accepted

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

ans = 0
prev = '#'
for i in range(N):
    if prev != S[i]:
        ans += 1
        prev = S[i]

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import math
import queue
#import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

def factorial(i):
    if i == 1:
        return 1
    else:
        return i*factorial(i-1)
 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)




def main(): #startline-------------------------------------------
    N = int(input())
    S = input()
    S +="A"
    keep = "start"
    ans = 0
    for i in S:
        if keep == "start":
            keep = i
        else:
            if keep == i:
                keep = i
            else:
                keep = i
                ans += 1
    print(ans)
                
if __name__ == "__main__":
    main() #endline===============================================

Submission status: Accepted

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

ans=1
before = s[0]

for i in range(N):
	if s[i] != before:
		ans+=1
		before = 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:
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:
def main():
    n=int(input())
    s=list(input())
    #d=list(map(int,input().split()))
    ans=1
    now=s[0]
    for i in range(n):
        if s[i]==now:
            continue
        else:
            ans+=1
            now=s[i]
    print(ans)
main()

Submission status: Accepted

Solution code:
N = int(input())
S = input()
cur = ""
ans = 0
for i in S:
    if cur == i:
        continue
    ans += 1
    cur = i
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
lst = list(input())
tot = 0
prev = '1'
for i in range(0,N):
    if lst[i] != prev:
        prev = lst[i]
        tot += 1
print(tot)

Submission status: Accepted

Solution code:
'''
import sys
input=sys.stdin.readline
n,m,c = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
from math import ceil
from collections import defaultdict ,Counter
'''
n = int(input())
s = input()
res = 1
t = s[0]
for i in range(1,n):
    if s[i] != s[i-1]:
        res+=1
        t = s[i]
print(res)

Submission status: Accepted

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

res = ''
for elem in s:
    if res == '':
        res += elem
    else:
        if res[-1] == elem:
            pass
        else:
            res += elem
print(len(res))

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()
cnt = 0 #消える数
for i in range(1,n):
    if s[i]==s[i-1]:
        cnt+=1
ans=n-cnt
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


N = read_a_int()
S = input()

s_pre = 'unko'
cnt = 0
for s in S:
    if s != s_pre:
        cnt += 1
        s_pre = s

print(cnt)

Submission status: Accepted

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

decreased = 0
prev_color = ""

for s in S:
    if s == prev_color:
        decreased += 1
    prev_color = s

print(N-decreased)

Submission status: Accepted

Solution code:
N = int(input())

S = input()

ans = 0

old = "0"
for index in range(N):
    if S[index] != old:
        ans += 1
    old = S[index]

print(ans)

Submission status: Accepted

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

ans = [[k , len(list(g))] for k, g in itertools.groupby(s)]
print(len(ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 1

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

Submission status: Accepted

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

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

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=list(input())
S=['0']+S
count=0
for n in range(N):
    a=S[n]
    b=S[n+1]
    count+=int(a!=b)
print(count)

Submission status: Accepted

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

c = ''
m = 0

for i in s:
    if c != i:
        m += 1
        c = i

print(m)

Submission status: Accepted

Solution code:
n=int(input())
s=input()
a=1
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()
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()
s=s+"X"
count=0
for i in range(len(s)-1):
    if s[i]!=s[i+1]:
        count+=1
print(count)

Submission status: Accepted

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

temp = 'dummy'
ans = 0
for s in S:
    if s != temp:
        ans += 1
    temp = s
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
s = input()
current = ""
ans = 0
for ss in s:
    if current != ss:
        ans += 1
        current = ss
    else:
        pass
print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
import sys


def readline():
    return sys.stdin.readline().rstrip()


def read(f=int):
    return f(readline())


def reads(f=int):
    return list(map(f, readline().split()))


def read_n(n: int, f=int):
    return [read(f) for _ in range(n)]


def reads_n(n: int, f=int):
    return [reads(f) for _ in range(n)]

N = read()
S = read(str)

slime = 0

prev = None
for s in S:
        if prev == s:
                continue
        slime += 1
        prev = s

print(slime)

Submission status: Accepted

Solution code:
N = int(input())
S = list(input())
char = S[0]
ans = 1
for i in range(1,N):
  if char==S[i]:
    continue
  else:
    char=S[i]
    ans+=1

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n=int(input())
s=input()+"A"
t=""
for i in range(n):
    if s[i]==s[i+1]:
        continue
    else:
        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()


s_list = list(S)

mix=0
for i in range(len(s_list) -1):
        if s_list[i] == s_list[i+1]:
                mix+=1



print(N-mix)

Submission status: Accepted

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

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+=0
  else:
    count+=1
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
_ = input()
S = input()

lastc = "0"
ans = 0

for c in S:
    if c != lastc:
        lastc = c
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
n = input()
t = n
s = raw_input()

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

Submission status: Accepted

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

ans=1
bef = s[0]
for i in range(1,n):
    now = s[i]
    if bef!=now:
        ans+=1
        bef = now
print(ans)

Submission status: Accepted

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

c = 0
temp = ''
for s in S:
  if s != temp:
    c += 1
    temp = s

print(c)

Submission status: Accepted

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

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

print(cnt)

Submission status: Accepted

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

rtn = 0
ma = "-"
for si in s:
    if (ma != si):
        rtn += 1
    ma = si

print(rtn)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from itertools import groupby
n=int(input())
s=input()
g=groupby(s)
a=[]
for i,j in g:
  a.append(i)
print(len(a))

Submission status: Accepted

Solution code:
def f_c():
    n = int(input())
    *s, = input()

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

if __name__ == "__main__":
    f_c()

Submission status: Accepted

Solution code:
def runlength(S):
    cnt = 1
    d = []
    for i in range(len(S)-1):
        if S[i] == S[i+1]:
            cnt += 1
        else:
            d.append(cnt)
            cnt = 1
    else:
        d.append(cnt)

    return d



def main():
    N = int(input())
    S = input()
    d = runlength(S)
    print(len(d))

  

if __name__ == "__main__":
    main()

Submission status: Accepted

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

result = 1

cur = s[0]

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

print(result)

Submission status: Accepted

Solution code:
import sys


def main():
    n = int(sys.stdin.readline().strip())
    s = sys.stdin.readline().strip()

    cur = '@'
    ans = 0
    for i in range(n):
        if cur != s[i]:
            ans += 1
        cur = s[i]
    print(ans)


main()

Submission status: Accepted

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

pre_s = '@'

ans = 0
for s in S:
    if s != pre_s:
        ans += 1
        pre_s = s
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:
import re
N = int(input())
S = input()
print(len(re.sub(r"(.)\1+", "!", S)))

Submission status: Accepted

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

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

Submission status: Accepted

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

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

N = INT()
S = input()

count = 1
for i in range(N-1):
    if S[i] == S[i+1]:
        continue
    else:
        count += 1
print(count)

Submission status: Accepted

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

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

Submission status: Accepted

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

tmp = ''
ans = ""
for one in s:
    if one == tmp:
        continue
    else:
        tmp = one
        ans += one
print(len(ans))

Submission status: Accepted

Solution code:
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

N=one_int()
S=one_str()

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

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 = 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,S=open(0);print(sum(s!=t for s,t in zip(S,S[1:])))

Submission status: Accepted

Solution code:
def read():
    N = int(input().strip())
    S = input().strip()
    return N, S

def rle_encode(S):
    S1 = S + '@'
    rle = list()
    head = 0
    for i in range(0, len(S1)):
        if S1[i] != S1[head]:
            rle.append((S1[head], i-head))
            head = i
    return rle

def solve(N, S):
    return len(rle_encode(S))

if __name__ == '__main__':
    inputs = read()
    print("%d" % solve(*inputs))

Submission status: Accepted

Solution code:
n = int(input())
s = input()+"?"

ans = 0
now = "?"
for i in range(n+1):
    if i == 0:
        now = s[i]
        continue

    if s[i] == now:
        continue
    else:
        ans += 1
        now = s[i]

print(ans)

Submission status: Accepted

Solution code:
s = input()
s = input()
res = 1
start = s[0]
for i in s:
  if start != i:
    res+=1
  start = i
print(res)

Submission status: Accepted

Solution code:
#import sys

#input = sys.stdin.readline



def main():
#    h,w,a,b = map(int, input().split())
    n=int(input())
    s=input()
    if n>=2:
        for i in range(1,n):
            if s[i]==s[i-1]:
                n-=1
    print(n)






if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())
S = input()
pre, ans = S[0], 1

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

print(ans)

Submission status: Accepted

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

s = "-1"
ans = 0

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

Submission status: Accepted

Solution code:
n = int(input())
tmp = ''
ans = 0
for c in input():
    if tmp != c:
        ans += 1
    tmp = c
print(ans)

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


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

print(N)

Submission status: Accepted

Solution code:
N = int(input())
S = list(input())
t = 0
pre = ''
for s in S:
    if pre == s:
        t += 1
    pre = s
print(N-t)

Submission status: Accepted

Solution code:
import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
mod = 10**9 + 7
inf = float('inf')
N = I()
S = str(input())
ans = int(0)
count = int(0)

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

ans = N -count

print(ans)

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

Submission status: Accepted

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

sra = []
moji = S[0]
for s in S[1:]:
    if moji != s:
        sra.append(moji)
        moji = s
sra.append(moji)
print(len(sra))

Submission status: Accepted

Solution code:
import sys
def main():
    N = int(input())
    S = input()
    now = 0
    count = 0
    while True:
        count += 1
        now_color = S[now]
        while now_color == S[now]:
            now += 1
            if now == N:
                print(count)
                exit()

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
#N=int(input())
#D=list(map(int,input().split()))
N=input()
S=input()
pre="#"
ans=0
for x in S:
	if (x!=pre):
		pre=x
		ans+=1
print(ans)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    s = list(input())
    ans = 0
    for i in range(n-1):
        if s[i]==s[i+1]:
            pass
        else:
            ans +=1
    print(ans+1)
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


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

    g = 1
    p = s[0]
    for i in s[1:]:
        if i != p:
            g += 1
            p = i

    print(g)


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

a = 0
p = None
for i in range(len(s)):
    if s[i] != p:
        a += 1
        p = s[i]
print(a)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
color = ""

for s in S:
    if color != s:
        color = s
        ans += 1
print(ans)

Submission status: Accepted

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

ans = S[0]
b = S[0]
for si in S[1:]:
    if si == b:
        continue
    else:
        ans += si
    b = si

print(len(ans))

Submission status: Accepted

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

def main():
    n = int(input())
    s = input()
    cnt = 1
    for i in range(len(s)-1):
        if s[i] == s[i+1]:
            continue
        else:
            cnt += 1
    print(cnt)


if __name__ == '__main__':
        main()

Submission status: Accepted

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

Submission status: Accepted

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

count = 1

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

print(count)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n=int(input())
s=input()
c=0 
i=0 
while i<n:
    curr=s[i]
    c+=1 
    while i<n and curr==s[i]:
        i+=1 
print(c)

Submission status: Accepted

Solution code:
# from collections import defaultdict
# from heapq import heappush, heappop, heapify
# from bisect import bisect_left, insort_left
# from itertools import groupby


class Solution:
    def main(self):
        N = int(input())
        # d = list(map(int, input().split()))
        s = input()
        res = 1
        for i in range(N-1):
            if s[i] != s[i+1]:
               res += 1
        print(res)


if __name__ == '__main__':
    Solution().main()

Submission status: Accepted

Solution code:
def c_slimes():
    from itertools import groupby
    N = int(input())
    S = input()

    ans = [k for k, v in groupby(S)]
    return len(ans)

print(c_slimes())

Submission status: Accepted

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

Submission status: Accepted

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

slimes = [s[0]]
for c in s[1:]:
  if c != slimes[-1]:
    slimes.append(c)
print(len(slimes))

Submission status: Accepted

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

sum = N

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

Submission status: Accepted

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

    pre = ''
    count = 0
    for i in range(n):
        if pre != s[i]:
            count += 1
        pre = s[i]
    print(count)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
from sys import stdin

N = int(stdin.readline().rstrip())
S = stdin.readline().rstrip()
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 -*-
#ABC143C
import sys
import math
import collections
#sys.setrecursionlimit(100000)


n=int(input())

s = input()
#tmp = input().split()
#a = list(map(lambda a: int(a), tmp))

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

print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#gcdは3.4.3だとfractionsにある
from fractions import gcd

from math import factorial as f

from math import ceil,floor,sqrt

from sys import exit

from copy import deepcopy
import numpy as np

import bisect
import re


ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))



def main():
    n = ii()
    s = input()

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


main()

Submission status: Accepted

Solution code:
N = int(input())
S = input().strip()
ans = 0
prev = ''
for i in S:
  ans += int(prev != i)
  prev = i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
  input()
  v = input().strip()
  s = 1

  for a, b in zip(v[:-1], v[1:]):
    if a != b:
      s += 1

  print(s)


if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
import sys; readline = sys.stdin.readline
from collections import deque

N = int(readline())
S = readline().rstrip()

count = 0

now = None

for c in S:
    if c != now:
        count += 1
    now = c

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)