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

count = 0
before = None
for c in S:
    if c != before:
        count += 1
    before = c

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

MOD = 10 ** 9 + 7

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

Submission status: Accepted

Solution code:
n = int(input())
s = list(input())
if n == 1:
  print(1)
  exit()
i,j = 0,1
ans = 1
while i<j:
  if s[i]==s[j]:
    j+=1
  else:
    ans+=1
    i=j
    j+=1
  if j==n:
    break
print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

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

ans = 0
before_s = 0
for ss in s:
    if before_s != ss:
       ans += 1
       before_s = ss
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=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 = 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:
import numpy as np


def main():
    N = int(input())
    S = input()
    count = 1
    now = S[0]
    for n in range(1, N):
        if(now != S[n]):
            count += 1
            now = S[n]
    print(count)


if(__name__ == "__main__"):
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

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

print(int(N))

Submission status: Accepted

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

i = 0
leght = n
result = list(colors[0])

for i in range(n-1):
  if colors[i] != colors[i+1]:
  	result.append(colors[i+1])
    
print(len(result))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    n = input()
    slimes = list(input())

    one = 0
    count = 0
    for slime in slimes:
        if one != slime:
            count+=1
        one = slime
    print(count)
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def main():
    n = input()
    slimes = list(input())
    cnt = 1
    for i in range(len(slimes)-1):
        if slimes[i] != slimes[i+1]:
            cnt+=1

    print(cnt)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
le = int(input())
lis = list(input())
alis = []
def delete(n,lis):
    for i in range(n):
        if i==n-1 or lis[i] != lis[i+1]  :
            alis.append(lis[i])
delete(le,lis)
print(len(alis))

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

print(len(S)-check)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(len(S)-check)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(count + 1)

Submission status: Accepted

Solution code:
def main(n,s):
    if n == 1:
        return 1
        
    count = 1
    for i in range(1,n):
        if s[i] != s[i-1]:
            count += 1
    return count

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


print(main(n,s))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

s = []
tmp = "temp"
for i in S:
    if tmp != i:
        s.append(i)
        tmp = i
    else: continue

print(len(s))

Submission status: Accepted

Solution code:
n = int(input())
s = input()
#s = "aaaaa"
s_list = list(s)
counter = 0
for m in range(1,len(s_list)):
  if s_list[m] == s_list[m-1]:
     counter += 1
print(len(s_list) - counter)

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 sys import stdin
n = int(stdin.readline().rstrip())
s = [x for x in stdin.readline().rstrip()]
a = 0
for i in range(len(s)):
    if not i == len(s) - 1:
        if s[i] == s[i+1]:
            a += 1
print(n-a)

Submission status: Accepted

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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def into_lan(s,n):
	ch = s[0]
	res = 0
	for i in range(1,n):
		if(s[i] != ch):
			res = res + 1
		ch = s[i]
	return res + 1

n = int(input())
body = input()
print(into_lan(body,n))

Submission status: Accepted

Solution code:
# ABC143C - Slimes
from itertools import groupby


def main():
    N = int(input())
    S = input().rstrip()
    ans = len(tuple(groupby(S)))
    print(ans)


if __name__ == "__main__":
    main()

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

print(ans + 1)

Submission status: Accepted

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

p=[]
#print(s)
for i in range(n-1):
  if s[i]==s[i+1]:
    p.append(i)
p.sort(reverse=True)
l=len(p)

for i in range(l):
    #print(p[i])
    s.pop(p[i])

print(len(s))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ret = s[0]
cur_col = s[0]
for i in s:
    if i != cur_col:
        cur_col = i
        ret += i

print(len(ret))

Submission status: Accepted

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

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

print(n)

Submission status: Accepted

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

prev = S[0]
cnt = 1
for i in range(1, N):
    if not prev == S[i]:
        cnt += 1
    prev = S[i]
print(cnt)

Submission status: Accepted

Solution code:
N = input()
re = [str(x) for x in input()]
s = [re[0]]
for n in range(len(re)-1):
  if not re[n] == re[n+1]:
    s.append(re[n+1])
  t = re[n+1]
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]:
        cnt += 1
print(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:
def T():
    N=int(input())
    c=''
    for s in input():
        if s==c:
            N-=1
        c=s
    return(N)
print(T())

Submission status: Accepted

Solution code:
def T():
    N=int(input())
    c=''
    t=0
    for s in input():
        if s==c:
            N-=1
        c=s
    return(N)
print(T())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8

n = int(input().rstrip())
l = list(input().rstrip())
count = i = 0

for i in range(1,n):
    if l[i] == l[i-1]:
        count += 1
        
print(n - 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:
length = int(input())
list = list(input())

counter = 0

for k in range(length-1):
    try:
        while True:
            if list[k] != list[k+1]:
                break
            list.pop(k+1)
    except:
        break


print(len(list))

Submission status: Accepted

Solution code:
m=input()
A=int(m)
n=input()
list =[]
sum = 1
for i in range(0,A):
    list.append(n[i])
    if (i!=0) & (list[i-1]!=list[i]):
        sum = sum+1
print(sum)

Submission status: Accepted

Solution code:
#
import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


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

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

sum = 0

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

print(N - sum)

Submission status: Accepted

Solution code:
n = int(input())
str = input()
char_list = list(str)
#del_num = []

count =0
ans =0

#dellist = lambda items, indexes: [item for index, item in enumerate(items) if index not in indexes]
for i in range(len(char_list)-1):
    if char_list[i] == char_list[i+1]:
        #del_num.append(i+1)
        count += 1

ans = n - count

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(n):
    if i==0:
        count = 1
    else:
        if s[i]!=s[i-1]:
            count += 1
        else:
            pass
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:
a = int(input())
s = input()
last = ''
counter = 0
for slime in s:
  if last != slime:
    counter += 1
    last = slime
print('{}'.format(counter))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
slime_num = int(input())
color_str = input()
ans = 0
pre_color = "aa"
same_color_check = 0
for i in color_str:
    if not same_color_check:
        if i == pre_color:
            same_color_check = 1
        else:
            ans += 1
            pre_color = i
    else:
        if i != pre_color:
            same_color_check = 0
            pre_color = i
            ans += 1
print(ans)

Submission status: Accepted

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

print(s)

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 = list(input())

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

print(ans)

Submission status: Accepted

Solution code:
import itertools
N = int(input())
x = list(input())

ct = 1
j = x[0]
for i in x:
    if(i != j):
        ct += 1
    j = i

print(ct)

Submission status: Accepted

Solution code:
def func():
    N = int(input())
    r = 0
    S = ''
    for s in list(input()):
        if S != s:
            r += 1
            S = s
    return r
print(func())

Submission status: Accepted

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

#print(N,S)
L=N
for j in range(N-1):
  if S[j]==S[j+1]:
    L -=1
    
print(L)

Submission status: Accepted

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

ans = list(S[0])
prev = S[0]

for c in S[1:]:
    if prev != c:
        ans.append(c)
    prev = c

print(len(ans))

Submission status: Accepted

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

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

Submission status: Accepted

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

c = 0
r = ''
for x in s:
    if x != r:
        c += 1
    r = x

print(c)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(1000000000)
ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())
INF = float('inf')

def main():
    N=ii()
    S=input()
    ans=[S[0]]    
    t=S[0]
    for i in range(1,len(S)):
        if S[i]!=t:
            t=S[i]
            ans.append(t)
    print(len(ans))
if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())
l = list(input())
r = 0
for i, s in enumerate(l):
    if i + 1 == N:
        r += 1
        print(r)
        break
    if s != l[i + 1]:
        r += 1

Submission status: Accepted

Solution code:

n = int(input())
s = input()
ans = ""
temp = s[0]

for i in s[1:]:
    if temp != i:
        ans += temp
        temp = i

print(len(ans)+1)

Submission status: Accepted

Solution code:
N = int(input())
l = list(input())
h = []
for i, s in enumerate(l):
    if i + 1 == N:
        h.append(s)
        print(len(h))
        break
    if s != l[i + 1]:
        h.append(s)

Submission status: Accepted

Solution code:
length = int(input())
li = list(input())
li2 = []
for i, str in enumerate(li):
    if i + 1 == length:
        li2.append(str)
        print(len(li2))
        break
    if str != li[i + 1]:
        li2.append(str)
        continue

Submission status: Accepted

Solution code:
length = int(input())
li = list(input())
li2 = []
i = -1
for str in li[:]:
    i = 1 + i
    if i + 1 == len(li):
        li2.append(li[i])
        print(len(li2))
        break
    if li[i] != li[i + 1]:
        li2.append(li[i])
        continue

Submission status: Accepted

Solution code:
length = int(input())
li = list(input())
i = 0
for n in li[:]:
    if i + 1 == len(li):
        print(len(li))
        break
    if li[i] == li[i + 1]:
       del (li[i + 1])
    else:
        i = 1 + i
        continue

Submission status: Accepted

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

prev = None

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

Submission status: Accepted

Solution code:
words = lambda t : list(map(t, input().split()))
n = int(input())
s = input()
prev = s[0]
ans = 1
for c in s:
    if prev != c:
        ans += 1
        prev = c

print(ans)

Submission status: Accepted

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

S_list = list(S)

num_slime = 1

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

print(num_slime)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
import itertools
import math
INF = 10**9
MOD = 10**9+7

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

Submission status: Accepted

Solution code:
import numpy as np
from collections import defaultdict
from functools import reduce

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

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

Submission status: Accepted

Solution code:
import re

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

t = re.sub(r'(.)\1{1,}', 'X', S)
print(len(t))

Submission status: Accepted

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

for i in range(1, n):
    if not 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=list(input())
a=[]
a.append(s[0])
for i in range(n-1):
  if s[i] != s[i+1]:
    a.append(s[i+1])
  else:
    continue
print(len(a))

Submission status: Accepted

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

#隣接するスライムを１つにまとめる関数yugouの定義
#引数はスライムのリストslimes
def yugou(slimes):
	temp = []
	for i in range(len(slimes)-1):
		if slimes[i] != slimes[i+1]:
			temp.append(slimes[i])
	temp.append(slimes[-1])
	return(temp)

#変化がなくなるまでyugou関数を繰り返す再帰関数f(x)
def f(x):
	y = yugou(x)
	if x == y:
  		ans = y
	else:
		y = f(x)
	return(ans)

temp_ans = yugou(slimes)
if temp_ans == slimes:
	ans=temp_ans
else:
	ans = f(temp_ans)

print(len(ans))

Submission status: Accepted

Solution code:
n = int(input())
s = input()
list_s = []
for i in range(n):
    list_s.append(s[i])

for i in range(n):
    try:
        while list_s[i] == list_s[i+1]:
            if list_s[i] == list_s[i+1]:
                list_s.pop(i+1)
    except IndexError:
        continue
print(len(list_s))

Submission status: Accepted

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

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

Submission status: Accepted

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

out = ""
i = 0
while True:
    end = False
    if i == N-1:
        out += S[i]
        break
    for j in range(i+1, N):
        if S[i] == S[j]:
            end = True
            continue
        else:
            out += S[i]
            i = j
    if end:
        out += S[i]
        break

print(len(out))

Submission status: Accepted

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

remain = [c for i,c in enumerate(s) if (i==0)|(s[i-1]!=c)]

print(len(remain))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    n, s = open(0).read().split()
    n = int(n)

    before_s = ''
    ans = 0
    for _s in s:
        if _s != before_s:
            ans += 1
            before_s = _s
        else:
            continue
    print(ans)
    return()

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    S = input()
    prev = ""
    ans = 0
    for c in S:
        if c != prev:
            ans += 1
            prev = c
    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()
l=[]
c=0
l.append(s[0])
for i in range(1,n):
  if(s[i]!=l[c]):
    c+=1
    l.append(s[i])    
print(c+1)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!


import sys
#sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 

n = int(input())
#d = [int(i) for i in readline().split()]
s = input()

from itertools import groupby

ans = 0
for i in groupby(s):
    ans += 1


print(ans)

Submission status: Accepted

Solution code:
a= input()

N=int(a[0])

#d=[int(input()) for _ in range(N)]
d=str(input())

check=d[0]
res=[]
res.append(d[0])

for i in range(len(d)):
  if check != d[i]:
    res.append(d[i])
    check=d[i]
    
print(len(res))

Submission status: Accepted

Solution code:
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n = int(input().rstrip('\n'))
    s = str(input().rstrip('\n'))
    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 = input()
cnt = 0
for i in range(1, N):
    if S[i] != S[i-1]:
        cnt += 1
print(cnt+1)

Submission status: Accepted

Solution code:
n = int(input())
s = input()
try:
    ch = s[0]
except :
    pass
su = 1
for c in range(1, n):
    if ch == s[c]:
        continue
    else:
        ch = s[c]
        su += 1

print(su)

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

counter=1

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

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()
 
s = 0
a = 1
while s<len(S):
    pattern = re.compile(r"[^%s]+?" % S[s])
    matchObj = re.search(pattern, S[s+1:])
    if matchObj:
        s += matchObj.start()+len(matchObj.group())
        a+=1
    else:
        break
print(a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
s = input()
a = [str(c) for c in s]
total=1

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

print(total)

Submission status: Accepted

Solution code:
_,s=open(0)

sl=list(s)

n=len(sl)

i=int(0)

while i<n-1:
    if sl[i]==sl[i+1]:
        sl[i]="rep"
        i+=1
    else:
        i+=1



print(len([j for j in sl if j!="rep"])-1)

Submission status: Accepted

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

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:
from itertools import groupby


def main():
    S = open(0).read().split()[1]
    print(sum(1 for x in groupby(S)))


main()

Submission status: Accepted

Solution code:
from itertools import groupby


def main():
    S = open(0).read().split()[1]
    print(len(list(groupby(S))))


main()

Submission status: Accepted

Solution code:
N = int(input())
S = list(input())
def app(S):
  for i in range(1,len(S)):
    if S[i] == S[i-1]:
      S[i] = ''
  S = [S[i] for i in range(len(S)) if S[i]!='']
  return S
while app(S) != S:
  S = app(S)
print(len(S))

Submission status: Accepted

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

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

pp = "#"
res = 0
for s in S:
	if s != pp:
		res += 1
	pp = s

print(res)

Submission status: Accepted

Solution code:
N = int(input())
S = input()
sum = 0
temp= ""

for i in list(S):
    if temp != i:
        temp = i
        sum+=1

print(sum)

Submission status: Accepted

Solution code:
n = int(input())
s = str(input())
result = ''
before = ''
count = 0
for i in range(len(s)):
    current = s[i]
    if current != before:
        result += current
        count += 1
    before = current
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def resolve():
    n = int(input())

    targets = input()
    ans = 1

    for i in range(len(targets)-1):
        if targets[i] == targets[i+1]:
            pass
        else:
            ans += 1

    print(ans)
resolve()

Submission status: Accepted

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

for i in S:
    count +=1
    if (count>=2) & (i==j): continue
    else:
        j=i
        ans += 1

print(ans)

Submission status: Accepted

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

c = s[0:1]
x = 1

for i in range(1,len(s)):
    # print(i,c,s[i:i+1],x)
    if s[i:i+1] != c:
        x = x + 1
        c = s[i:i+1]
print(x)

Submission status: Accepted

Solution code:
N=int(input())
S=input()
S_list=[]
count = 0
j=''

for i in S:
    count +=1
    if (count>=2) & (i==j): continue
    else:
        S_list.append(i)
        j=i

print(len(S_list))

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:
N = int(input())
S = list(input())
before = ""
count = 0
for i in range(N):
    if S[i] != before:
        count  = count + 1
    before = S[i]
print(count)

Submission status: Accepted

Solution code:
import sys
N = int(sys.stdin.readline())
S = sys.stdin.readline()

ans = 1

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
S = list(input()) + ['end']
cnt = 0

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

Submission status: Accepted

Solution code:
N = int(input())
S = list(input())
start = 0
intervals = [S[0]]

for i in range(1, N):
    if S[start] != S[i]:
        intervals.append(S[i])
    start = i
print(len(intervals))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
x = list(input())
for i in range(len(x)-1):
  if x[i] == x[i+1]:
    x[i] = ''
print(len(''.join(x)))

Submission status: Accepted

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

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

print(N-sum_)

Submission status: Accepted

Solution code:
import itertools as i
_,S=open(0)
print(len(list(i.groupby(S)))-1)