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:
import sys
sys.setrecursionlimit(1000000)

a =int(input())
B =list(input())

def dfs(x):
    
    C =B[x]
    B[x] = "."
    nx = x + 1
    if nx >= 0 and nx <= a-1 and B[nx] == C:
        dfs(nx)

res = 0
for i in range(a):
        if B[i] != ".":
            # Wが残っているならそこから dfs をはじめる
            dfs(i)
            res += 1
print(res)

Submission status: Accepted

Solution code:
import itertools

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

list2 = [k for k, v in itertools.groupby(S)]

print(len(list2))

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

Submission status: Accepted

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

ans = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

flag = True
while flag:
    flag = False
    i = 0
    while i+1 < len(s):
        if s[i] == s[i+1]:
            flag = True
            s = s[:i] + s[i+1:]
            i += 1
        i += 1

print(len(s))

Submission status: Accepted

Solution code:
"""
author : halo2halo
date : 19,Oct,2019
"""

import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

N = int(readline())
words = readline().rstrip()
preword = '1'
ans = 0
for word in words:
    if preword != word:
        ans += 1
        preword = word

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:
n = int(input())
s = list(input())
p = []
i = 0
while i < n:
    if i < n-1 and s[i] == s[i+1]:
        p.append(s[i])
        i += 1
        while i < n-1 and s[i] == s[i+1]:
            i += 1
        i+=1
    else:
        p.append(s[i])
        i += 1
print(len(p))

Submission status: Accepted

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

pre = ''
sum = 0
for i in S:
  if pre != i:
    sum += 1
  pre = i
print(sum)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline

if __name__ == '__main__':
    N = int(input())
    S = input().strip()
    current_color = ''

    count = 0
    for s in S:
        if current_color != s:
            count += 1
        current_color = s

    print(count)

Submission status: Accepted

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

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

print(C)

Submission status: Accepted

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

total = []
Y = 0

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

Submission status: Accepted

Solution code:
n = int(input())

l = str(input())

ans = int(1)

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n1 =[]
A = int(input())
S = list( input().split()) 
L = list(S[0]) 
for x, y in zip(L, L[1:]):
    if x is not y:
      n1.append(x)
print(len(n1) + 1)

Submission status: Accepted

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

s0 = s.pop()

cnt = 1

while s:
    s1 = s.pop()
    if s1!=s0:
        cnt += 1
        s0 = s1
print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
t = input()
k = [1]
z = 0
s = t[0]
for i in range(1,n):
    if(t[i-1]==t[i]):
        z+=1
    else:
        z=0
    if(z==0):
        k.append(1)
    else:
        z=0

print(len(k))

Submission status: Accepted

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

Submission status: Accepted

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

cur_c = ""
result = ""

for c in s:
    if c == cur_c:
        continue
    else:
        cur_c = c
        result += c

print(len(result))

Submission status: Accepted

Solution code:
A=int(input())
B=list(input())

flag = 1
for i in range(A):
  if i < A-1:
    if B[i] != B[i+1]:
      flag+=1

print(flag)

Submission status: Accepted

Solution code:
n=int(input())
s=list(input())
i=0
while i<n-1:
    if s[i]==s[i+1]:
        s[i]=0
    
    i+=1

c=s.count(0)
print(n-c)

Submission status: Accepted

Solution code:
N = str(input())
S = list(input())
answer = []

for s in S:
  if len(answer) == 0:
    answer.append(s)
  elif answer[-1] != s:
    answer.append(s)
print(len(answer))

Submission status: Accepted

Solution code:
def conbine(text):
    flag = text[0]
    ans = str(flag)

    for i in text:
        if i == flag:
            None
        else:
            ans += str(i)
            flag = i
            continue
            
    ans_num = len(ans)
    return ans_num

input()
print(conbine(input()))

Submission status: Accepted

Solution code:
import sys

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

a = 0
while True:
    if a == len(S)-1:
        break

    if S[a] == S[a+1]:
        S = S[:a+1]+S[a+2:]
    else:
        a += 1

print(len(S))

Submission status: Accepted

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

ans = 1

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

print(ans)

Submission status: Accepted

Solution code:
a = int(input().split()[0])
b = list(map(str, input().split()[0]))
k = 0
s = 1
#print(a)
#print(b)
while k<len(b) -1:
 t = b[k]
 u = b[k+1]
 #print("t",t,"u",u)
 if not t == u:
  s = s + 1
  #print(s)
 k = k + 1
print(s)

Submission status: Accepted

Solution code:
# coding: utf-8
num = int(input())
colors = list(input())
count = 0

for i in range(num-1):
  if colors[i] != colors[i+1]:
    count += 1
  
print(count+1)

Submission status: Accepted

Solution code:
import re

N = input()
S = input()

for i in set(S):
    i_ = i + '+'
    pattern = re.compile(r'%s' % i_)
    S = re.sub(pattern, i, S)
    
print(len(S))

Submission status: Accepted

Solution code:
n = int(input())
src = list(input())
count = 0
for i,s in enumerate(src):
    if i == len(src)-1:
        break
    if src[i] == src[i+1]:
        count += 1
print(n - count)

Submission status: Accepted

Solution code:
N = int(input())
S = input()
before_slime = S[0]
slime_num = 0 if len(S) > 1 else 1
same_flg = False
for i, slime in enumerate(S[1:]):
    if before_slime == slime and i == len(S[1:])-1:
        slime_num += 1
    elif before_slime != slime and i == len(S[1:])-1:
        slime_num += 2
    elif before_slime == slime and same_flg:
        before_slime = slime
    elif before_slime != slime and same_flg:
        slime_num += 1
        before_slime = slime
        same_flg = False
    elif before_slime == slime:
        before_slime = slime
        same_flg = True
    else:
        slime_num += 1
        before_slime = slime
print(slime_num)

Submission status: Accepted

Solution code:
from itertools import groupby

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

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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
D = input()
S=list(D)
C = 1
X = S[0]
for i in range(N-1):

	if S[i+1]!=X:
		C+=1
		X=S[i+1]

print(C)

Submission status: Accepted

Solution code:
import re
N = int(input())
S = input()
oldS = S
while 1:
    S = re.sub('a+','a',S)
    S = re.sub('b+','b',S)
    S = re.sub('c+','c',S)
    S = re.sub('d+','d',S)
    S = re.sub('e+','e',S)
    S = re.sub('f+','f',S)
    S = re.sub('g+','g',S)
    S = re.sub('h+','h',S)
    S = re.sub('i+','i',S)
    S = re.sub('j+','j',S)
    S = re.sub('k+','k',S)
    S = re.sub('l+','l',S)
    S = re.sub('m+','m',S)
    S = re.sub('n+','n',S)
    S = re.sub('o+','o',S)
    S = re.sub('p+','p',S)
    S = re.sub('q+','q',S)
    S = re.sub('r+','r',S)
    S = re.sub('s+','s',S)
    S = re.sub('t+','t',S)
    S = re.sub('u+','u',S)
    S = re.sub('x+','x',S)
    S = re.sub('y+','y',S)
    S = re.sub('z+','z',S)
    S = re.sub('v+','v',S)
    S = re.sub('w+','w',S)
    if oldS == S:
        break
    else:
        oldS = S

print(len(S))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
s=list(input())
sura=0
qoq=list()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# n = int(input())
n = input()
s = list(input())
# a,b,c = map(int, input().split())
# d = list(map(int, input().split()))
tmp = ""
ans = ""
for word in s:
  if word != tmp:
    ans += word
  tmp = word
print(len(ans))

Submission status: Accepted

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

count =len(S)

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

print(count)

Submission status: Accepted

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


result = []
for i, s in enumerate(list(S)):
    if i == 0:
        result.append(s)
        continue

    if result[-1] == s:
        continue
    else:
        result.append(s)

print(len(result))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
num = int(input())
colorlist = list(input())
count = 0
dumy = None

for i in range(0, num): 
  if dumy != colorlist[i]:
    count+=1
  dumy = colorlist[i]
print(count)

Submission status: Accepted

Solution code:
n = int(input())
h = str(input())
h = list(h)
h2 = []
def mojiretu(n, h):
    h2.append(h[0])
    for i in range(1, len(h)):
            if h[i] != h[i - 1]:
                h2.append(h[i])
    return len(h2)
print(mojiretu(n,h))

Submission status: Accepted

Solution code:
slime_number = int(input())
slime_colors = list(input())

last_slime = 'ほげ'
result = 0

for i in range(slime_number):
  if last_slime != slime_colors[i]:
    last_slime = slime_colors[i]
    result += 1

print(max(result, 1))

Submission status: Accepted

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

cnt = 1
cur = S[0]
for c in S[1:]:
    if c != cur:
        cnt += 1
        cur = c
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=list(input())
a=[0]*n
new=[]
for i in range(n):
	if i==n-1:
		a[n-1]=1
		break
	if s[i]==s[i+1]:
		a[i]=0
	else:
		a[i]=1

for i in range(n):
	if a[i]==1:
		new.append(s[i])	
			

print(len(new))

Submission status: Accepted

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

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

slimes = [S[0]]
count = 0

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

print(len(slimes))

Submission status: Accepted

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

N = input()
S = input()
r = []
for s in S:
    if len(r) == 0 or r[-1] != s:
        r.append(s)
print(len(r))

Submission status: Accepted

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

r = 1
for i in range(N):

    if i + 1 != N:
        if S[i] == S[i+1]:
            pass
        else:
            r = r + 1
    else:
        pass

print(r)

Submission status: Accepted

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

prior = ""
fusion = ""
for i in range(N):
  if prior != S[i]:
    fusion += S[i]
  prior = S[i]
  #print(prior, end="")
print(len(list(fusion)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

S = input()

p = '!'

ans = 0

for i in range(N):
    if S[i] == p:
        pass
    else:
        ans += 1
    p = S[i]
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
li=list(input())
li.append("end")
i=0
while li[i]!="end":
	while li[i]==li[i+1]:
  		del li[i+1]
	i+=1
print(len(li)-1)

Submission status: Accepted

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

#print(S)
print(len(S))

Submission status: Accepted

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

if N > 0:
  ans = 1
else :
    print(0)
    sys.exit(0)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
S = list(input())
cou = 0
tmp = S[0]
for s in S[1:]:
  if tmp == s:
    cou += 1
  else:
    tmp = s
print(N-cou)

Submission status: Accepted

Solution code:
input1 = int(input())
input2 = str(input())

result_string = []
for i in range(input1):
    if i > 0 and input2[i] != input2[i-1]:
        result_string.append(input2[i])
    elif i == 0:
        result_string.append(input2[i])
#print(''.join(result_string))
print(len(result_string))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
_ = input()
input_slime_list = list(input())

remain_slime_list = []
for slime in input_slime_list:
    if len(remain_slime_list)==0:
        remain_slime_list.append(slime)
    else:
        if slime!=remain_slime_list[-1]:
            remain_slime_list.append(slime)

print(len(remain_slime_list))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(n)

Submission status: Accepted

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

import itertools

print(len([[k, len(list(g))] for k, g in itertools.groupby(S)]))

Submission status: Accepted

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

def fusion(list_s):
  fusioned_s = ''
  for index, char in enumerate(list_s):
    if index != len(list_s) -1 and char != list_s[index + 1]:
      fusioned_s += char
    elif index == len(list_s) -1:
      fusioned_s += char
      
  return fusioned_s

print(len(fusion(s)))

Submission status: Accepted

Solution code:
import itertools

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

print(len([k for k, v in itertools.groupby(S)]))

Submission status: Accepted

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

cnt = 1
cp = s[0]
for i in range(1, n):
  if s[i] != cp:
#    print ('CNT INC at ' + str(s[i]))
    cnt += 1
  cp = s[i]
#  print ('CP=' + str(cp))

print (cnt)

Submission status: Accepted

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

count = 1
while count != len(s) :
	count = 1
	for i in reversed(range(1,len(s))):
		
		if s[i] == s[i-1]:
			s.pop(i)
		else:
			count +=1


print(len(s))

Submission status: Accepted

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

checklist = []

for i in range(N-1):
    j = i+1
    if S[i] != S[j]:
        checklist.append(S[i])
print(len(checklist)+1)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(100000)

def ins(): return input().split()
def ii(): return int(input())
def iil(): return list(map(int, ins()))
def lin(): return list(input())
def iin(): return map(int, ins())


n = ii()
k = input()
t = ''
ans = 0
for i in k:
    if t!=i:
        ans += 1
        t = i
print(ans)

Submission status: Accepted

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


def solve(N: int, S: str):
    result = 0
    for s in set(S):
        regex = re.compile(s + "+")
        # print(regex.findall(S))
        result += len(regex.findall(S))
    print(result)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = map(int, input())
S = input()
S_list = list(S) #これで一文字ずつの配列にする
S_list_process = []

#10
#aabbbbaacaならabacaになる。

checkchar = ""
for char in S_list:
    if checkchar != char:
        S_list_process.append(char)
        checkchar = char

print(len(S_list_process))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(int(1e6))

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

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

Submission status: Accepted

Solution code:
import sys
N=int(input())
s=list(str(input()))
i=0
ans=0
if N==1:
  print(1)
  sys.exit()
while i!=N-1:
  count=1
  ans+=1
  while i+count<=N-1 and s[i]==s[i+count]:
    count+=1
  i+=count
  if i==N:
    print(ans)
    sys.exit()
  elif i==N-1:
    if s[N-2]!=s[N-1]:
      ans+=1
    print(ans)
    sys.exit()
print(ans)

Submission status: Accepted

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

k = 0
p = ''
count = 1

for s in S:
	if k != 0:
		if p == s:
			pass
		else:
			count += 1
	p = s
	k += 1
print(count)

Submission status: Accepted

Solution code:
N = int(input())
array = list(input())
now_value=""
for item in array:
	if item == now_value:
  		N = N-1
	else:
		now_value = item
print(N)

Submission status: Accepted

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

Submission status: Accepted

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

def p(S):
  s = len(S)
  e = 0
  cnt = 0
  while s != e:
    cnt += 1
    if cnt > N:break
    s = len(S)
    for i in range(s-1):
      if i >= len(S)-1:break
      if S[i] == S[i+1]:S.pop(i)
      e = len(S)
  return len(S)

print(p(S))

Submission status: Accepted

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

Submission status: Accepted

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

#print (s[0])
c = s[0]
cnt = 1
for i in range(1,n):
    if(c == s[i]):
        pass
        #print(c,s[i])
    else:
        cnt += 1
        c = s[i]
        
print (cnt)

Submission status: Accepted

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

len = 1

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

print(len)

Submission status: Accepted

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

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

ans= len(w)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

for i, e in enumerate(sl):
    if i > 0:
        if e == sl[i-1]:
            anssl[i-1] = False
ans = [i for i in anssl if i != False]
print(len(ans))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())
s = input()
ans = ''
temp = ''
for i in range(N):
    if(s[i] != temp):
        temp = s[i]
        ans += s[i]
print(len(ans))

Submission status: Accepted

Solution code:
a=int(input())
b=input() # 114514 810 893
c=list(b)
d=[]
for i in range(a-1):
  if c[i]==c[i+1]:
    d.append(0)
  else:
    d.append(1)
print(sum(d)+1)

Submission status: Accepted

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

sum = 1
s_list = list(s)[1:]
# print(s_list)
checker = list(s)[0]
# print(checker)
for c in list(s_list):
    if (c != checker):
        sum = sum + 1
        checker = c

print(sum)

Submission status: Accepted

Solution code:
def main():
    number_of_slimes = int(input())
    slime_list = list(input())

    print(len(remove_adjacent(slime_list)))
    # print(len(remove_adjacent(slime_list)))

def remove_adjacent(li):
    n1  = []
    n1.append(li[0])

    for i in range(1,len(li)):
        if li[i] != li[i-1]:
            n1.append(li[i])
    return n1

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re

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

rex = r'(.)\1{0,}'
pattern = re.compile(rex)
ans = pattern.findall(S)

print(len(ans))

Submission status: Accepted

Solution code:
N = int(input())
S = input()
tmp = S[0]
ret = tmp
for i in S:
  if tmp == i:
    tmp = i
  else:
    ret += i
    tmp = i
print(len(ret))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
num = int(input())
colors = list(input())
i = 0
while i+1 != len(colors):
  if colors[i] == colors[i+1]:
    colors.pop(i+1)
  else:
    i += 1
print(len(colors))

Submission status: Accepted

Solution code:
N = input()
S = input()
S = list(S)
m = []
for i, s in enumerate(S):
  if i == 0:
    m.append(s)
  if i >= 1 and S[i] != S[i - 1]:
    m.append(s)
print(len(m))

Submission status: Accepted

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

tmpS = ''
for key, value in groupby(S):
  tmpS = tmpS + key

print(len(tmpS))

Submission status: Accepted

Solution code:
import re
N = int(input())
S = input()
while re.search("(.)\\1",S):
    S = re.sub("(.)\\1", "\\1", S)
print(len(S))

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

a = s[0]
ans = list(s[0])
for i in range(1,len(s)):
    if a != s[i]:
        a = s[i]
        ans.append(s[i])

print(len(ans))

Submission status: Accepted

Solution code:
# 1行目の入力を数値として扱う
n = int(input())
# 2行目の入力をリストとして扱う
s = input()

ans = s[0]

#
for i in range(1, len(s)):
#    print(s[i - 1] + "," + s[i])
    if s[i - 1] == s[i]:
        continue
    ans += s[i]
        

#
print(len(ans))

Submission status: Accepted

Solution code:
import sys
from collections import Counter, deque, defaultdict
from math import factorial
import heapq, bisect
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

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

print(res)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
s=input()
t=0
for i,c in enumerate(s):
  if i>0 and c==s[i-1]:
    pass
  else:
    t+=1
print(t)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# 入力
N = int(input())
S = input()

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

print("{}".format(len(S2)))

Submission status: Accepted

Solution code:
import itertools
n = 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 = list(input())
c = 0
for i in range(1, n):
    if s[i-1] == s[i]:
        c+=1
        s[i-1] = ""
print(len(sorted(s)[c:]))

Submission status: Accepted

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

    for i in range(N):
        if tmp != S[i]:
            A += S[i]
        tmp = S[i]
    print(len(A))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import numpy as np

n = input()
s = np.array(list(input()))
n = int()

color = int(1)

for index,value in enumerate(s[1:]):
  if value != s[index]:
    color += 1

print(color)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8


def solve(*args: str) -> str:
    n = int(args[0])
    s = args[1]

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

    return str(q)


if __name__ == "__main__":
    print(solve(*[input() for _ in range(2)]))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
N = int(input())
S = input()
sum = 1
for i in range(1, N):
  if S[i] != S[i-1]:
    sum+=1
print('{}'.format(sum))

Submission status: Accepted

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

count = 1

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

print(count)

Submission status: Accepted

Solution code:
import re
N = input()
S = input()
slimes = re.sub('(.)\\1{1,}', 'X', S)
print(len(slimes))

Submission status: Accepted

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

print(len([n for i, n in enumerate(b) if i == 0 or n != b[i-1]]))

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
s=str(input())
for i in range(n-1):
	if s[i]==s[i+1]:
		s = s[:i] + 'X' + s[i+1:]
print(len(s.replace('X', '')))

Submission status: Accepted

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


def solve(N: int, S: str):
    l = list(S)
    while (True):
        sl = []
        cur = ''
        for v in l:
            if cur == v:
                continue
            sl.append(v)
            cur = v
        if len(l) == len(sl):
            print(len(l))
            break
        l = sl
    return


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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from itertools import groupby
n = input()
s = list(input())
cnt = 0
for _ in groupby(s):
    cnt = cnt + 1
print(cnt)

Submission status: Accepted

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

prev = s[0]
count = 1

for i in s:
    if i != prev:
        count += 1
    prev = i

print(count)

Submission status: Accepted

Solution code:
N = input()
d = sorted(map(str, input().split()))
cnt = 0
tmp = ''
for i in range(0, int(N)):  
    if d[0][i] != tmp:
        cnt += 1
    tmp = d[0][i]

print(cnt)