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
readline = sys.stdin.buffer.readline

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

ans = ""

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

print(len(ans))

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
from itertools import groupby

n = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()
new = str()

for key, value in groupby(s):
    new += key

print(len(new))

Submission status: Accepted

Solution code:
from sys import stdin
from itertools import groupby

n = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()
new = []

for key, value in groupby(s):
    new.append(key)

print(len(new))

Submission status: Accepted

Solution code:
from sys import stdin
from itertools import groupby

n = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()
l = [x for x in s]
new = []

for key, value in groupby(l):
    new.append(key)

print(len(new))

Submission status: Accepted

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

ans = ''

cache = ''

for s in S:
    if cache == '':
        ans += s
        cache = s
        continue
    if cache == s:
        continue
    else:
        ans += s
        cache = s

print(len(ans))

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)
#print(check)

check = reversed(check)

for i in check:
    s.pop(i)
    
print(len(s))

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()
a = '0'
ans = 0
for i in list(s):
	if a != i:
		ans += 1
		a = i

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()
cnt=0
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] != s[i+1]:
        count += 1
print(count)

Submission status: Accepted

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

cnt = 0
for i in range(N-1):
    if S[i] < S[i+1] or S[i] > S[i+1]:
        cnt += 1
print(cnt+1)

Submission status: Accepted

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

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

Submission status: Accepted

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

before_i = s[0]

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
S=input()
count=1
for n in range(1,N):
    if S[n]!=S[n-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

print(ans)

Submission status: Accepted

Solution code:
import array
import sys
from collections import deque

def input():
    return sys.stdin.readline().rstrip('\n')

N = int(input())
S = deque(list(input()))
last = S.pop()
count = 1
while(not len(S)==0):
    s = S.pop()
    if not s == last:
        count +=1
        last = s
    else:
        continue
    
print(count)

Submission status: Accepted

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

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

Submission status: Accepted

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

base = s[0]
count = 1

for i in range(1,num):
  if not base == s[i]:
    count = count + 1
    base = s[i]

print(count)

Submission status: Accepted

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

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

Submission status: Accepted

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


def main():
    N = int(input())
    S = input()
    result = None

    for s in S:
        if result is None:
            result = s
        elif result[-1] != s:
            result += s

    print(len(result))


if __name__ == "__main__":
    main()

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

Submission status: Accepted

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

def main():
  n = int(input())
  Ss = list(input().strip())
  ans = [Ss[0]]
  for S in Ss[1:]:
    if ans[-1] == S:
      continue
    else:
      ans.append(S)
  print(len(ans))
  
if __name__=='__main__':
  main()

Submission status: Accepted

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

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(cnt)

Submission status: Accepted

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    S=ST()
    b = ""
    a = 0
    for s in S:
        if b!=s:
            b = s
            a += 1
    print(a)
if __name__ == '__main__':
    main()

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

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

"""
def remove_adjacent(nums):
  i = 1
  while i < len(nums):    
    if nums[i] == nums[i-1]:
      nums.pop(i)
      i -= 1  
    i += 1
  return nums

remove_adjacent(s)
print(len(s))
"""

Submission status: Accepted

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

Submission status: Accepted

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

def remove_adjacent(nums):
  i = 1
  while i < len(nums):    
    if nums[i] == nums[i-1]:
      nums.pop(i)
      i -= 1  
    i += 1
  return nums

remove_adjacent(s)
print(len(s))

Submission status: Accepted

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

Submission status: Accepted

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

ans = s[0]
prev = s[0]

for i in s:
  if i != prev:
    ans += i
    prev = i
    
print(len(ans))

Submission status: Accepted

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

s = S[0]
i = 1
ans = 1
while(True):
    
    if i == len(S):
        break
    if s == S[i]:
        pass
    else:
        ans += 1
        s = S[i]
    i += 1
        
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
S = input()
now = "?"

ans = N
for s in S:
    if s == now:
        ans -= 1
        continue
    else:
        now = s

print(ans)

Submission status: Accepted

Solution code:
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    S = input().strip("\n")
    S += "0"
    count = 0
    nowCol = S[0]
    for i in range(1, N + 1):
        if S[i] != nowCol:
            count += 1
            nowCol = S[i]
    print(count)

    return 0

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    n = int(input())
    s = input()

    ans = s[0]
    tmp = s[0]

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

    print(str(len(ans)))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def main():
    N=int(input())
    S=input()
    c=1
    for i in range(N):
        if i==0:
            s=S[i]
        else:
            if s==S[i]:
                pass
            else:
                s=S[i]
                c+=1
    print(c)
if __name__=="__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    S = input()
    from itertools import groupby
    ans = 0
    for k, v in groupby(S):
        ans += 1
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

before_s = S[0]
ans = ''
for i in range(1, len(S)):
    if S[i] != before_s:
        ans += S[i]
        before_s = S[i]

print(len(ans)+1)

Submission status: Accepted

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

cnt=0

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

print(cnt+1)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
B = list(input())
total = 0
letter = 0
for i in B:
    if letter != i:
        total += 1
        letter = i
    else:
        pass
print(total)

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

p = ''
q = 0
for i in range(n):
  if p == s[i]:
    continue
  elif p != s[i]:
    p = s[i]
    q += 1
print(q)

Submission status: Accepted

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

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

print(c)

Submission status: Accepted

Solution code:
n = int(input())
s = str(input())
cnt = 0
hikaku = ""

for i in s:
    if i == hikaku:
        pass
    else:
        cnt += 1
        hikaku = i
print(cnt)

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:
length = input()
string = input()

color = 1
prev = string[0]
modified = string[0]


for c in string :
    if c == prev :
        continue
    else :
        prev = c
        color = color + 1
        modified = modified + c

print(color)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
s = input()
a = []
ss = list(s)
old = ""
ans = ""
for i in ss:
	if old != i:
		ans += i
		old = i
print (len(ans))

Submission status: Accepted

Solution code:
N=int(input())
S=list(input())
cnt=1
tmp=S[0]

for n,i in enumerate(S):
  if(n!=0):
    if(tmp!=i):
      cnt+=1
      tmp=i
print(cnt)

Submission status: Accepted

Solution code:
from functools import reduce

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

B = ""
R = ""
for s in S:
    if B != s:
        R += s
        B = s

print(len(R))

Submission status: Accepted

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

back = S[0]
for i in range(1, L):
	if back == S[i]:
		S[i] = ""
	else:
		back = S[i]

S = "".join(S)
print(len(S))

Submission status: Accepted

Solution code:

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

#print(s)

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

print(ans)

Submission status: Accepted

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

sumx = 0
mem = ""

for i in S:
    if i != mem:
        sumx += 1
        mem = i
    else:
        mem = i

print(sumx)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = input()
S = input()
_ = ""
ans = 0
for s in S:
    if s != _:
        ans += 1
    _ = s
print(ans)

Submission status: Accepted

Solution code:
import math

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

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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
S = input()
X = []
tmp = 0
for s in S:
    if s != tmp:
        tmp = s
        X.append(s)
ans = len(X)
print(ans)

Submission status: Accepted

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

count = 0
prev_s = ""

for s in S:
    if prev_s != s:
        count += 1
        prev_s = s

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())

s=input()

memo = ''

count = 0

for i in range(n):
    if i == 0:
        memo = s[0]
        count += 1
    elif memo == s[i]:
        continue
    else:
        memo = s[i]
        count += 1
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
s=list(input())
s2=[]
t=""
for s1 in s:
 if t!=s1:
     s2.append(t)
 t=s1


print(len(s2))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())
S = list(input())
ans = len(S)
cur = S[0]

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(len(''.join(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 += 1

print(count)

Submission status: Accepted

Solution code:
#python3

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

chars = list(input())

if n == 0:
    print(0)
elif n == 1:
    print(1)
else:
    slime_num = 1
    idx_0 = 0
    idx_1 = 1
    
    while idx_1 < n:
        if chars[idx_0] != chars[idx_1]:
            slime_num += 1
        idx_1 += 1
        idx_0 += 1
    
    print(slime_num)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    S = input()
    s = ''
    r = 0
    for i in S:
        if s == i:
            continue
        s = i
        r += 1
    print(r)
main()

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(n):
    if not i+1 >= n and s[i]==s[i+1]:
        pass
    else:
        ans+=1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
S = list(input())
mix = []

now = S[0]
for i in range(1,len(S)):
    if now != S[i]:
        mix.append(now)
        now = S[i]

print(len(mix)+1)

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

Submission status: Accepted

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

for i in range(1,n):
    color1 = s[i-1]
    color2 = s[i]

    if color1==color2:
        slime -= 1

print(slime)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import groupby
input()
s=input()
print(len(list(groupby(s))))

Submission status: Accepted

Solution code:
import itertools
import math
import sys

n = int(input())
s = input()
index = 1
ans = 1
last_letter = s[0]
while index < n:
    if s[index] != last_letter:
        ans += 1
        last_letter = s[index]
    index += 1
print(ans)

Submission status: Accepted

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

ans = [1]
tmp = S[0]
cnt = 0
for s in S[1:]:
    if tmp == s:
        cnt += 1
        tmp = s

    else:
        ans.append(cnt)
        cnt = 0
        tmp = s

print(len(ans))

Submission status: Accepted

Solution code:
N=int(input())
S=input()
mozi=list(S)
n=0
cnt=0
while n<N-1 :
    if mozi[n]==mozi[n+1]:
        cnt+=1
    n+=1
print(N-cnt)

Submission status: Accepted

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

ans = N

for i, s in enumerate(S[1:]):
  if s==S[i]:
    ans -= 1
    
print(ans)

Submission status: Accepted

Solution code:
"""
author : halo2halo
date : 4, Feb, 2020
"""

import sys

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
S = [str(i) for i in readline().decode('utf8').strip()]
ans = 0
for s, t in zip(S, S[1:]):
    if s != t:
        ans += 1
print(ans + 1)

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

print(ans+1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

n = int(input())
s = list(input())
print(main(n,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]:
        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 = 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())
sl = list(input())
ss = []

if n == 1:
    print(1)
else:
    for i in range(1, n):
        if sl[i] != sl[i-1]:
            ss.append(sl[i-1])
        if i == n-1:
            ss.append(sl[i])
    print(len(ss))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
n=int(input())
s=str(input())
slime=itertools.groupby(s)
count=0
for key,value in slime:
  count+=1
print(count)

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

count=1

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

Submission status: Accepted

Solution code:
N = int(input())
S = input()
count = 1
color = S[0]
for s in S:
  if s != color:
    count += 1
    color = s
print(count)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	N = II()
	S = IS()
	ls = [S[0]]
	for s in S[1:]:
		if(ls[-1]!=s):
			ls.append(s)
	print(len(ls))

main()

Submission status: Accepted

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

for i in range(1,len(s)):
    if s[i-1]==s[i]:
        s[i-1] = "" 
        
for i in range(n):
    if s[i] != "":
        #print(s[i])
        ans.append(s[i])
moji = ''.join(ans)
print(len(moji))

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
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()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
S = input()

for i in range(len(ascii_lowercase)):
	S = re.sub(ascii_lowercase[i] + "+", ascii_lowercase[i], S)

print(len(S))

Submission status: Accepted

Solution code:
input()
slimes = input()

count = 1

be = slimes[0]
for x in slimes[1:]:
  if be != x:
    count += 1
    be = x

print(count)

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:
N = int(input())
S = input()

l = [S[0]]
for s in S[1:]:
    if s!=l[-1]:
        l.append(s)

print(len(l))

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(result)