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

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

Submission status: Accepted

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


def main():
    sc = Scan()
    n = sc.intarr()[0]
    s = sc.strarr()[0]
    ans = ''
    before = s[0]
    for i in range(1, n):
        c = s[i]
        if before != c:
            ans += before
            before = c

    ans += before
    print(len(ans))


class Scan():

    def intarr(self):
        line = input()
        array = line.split(' ')
        num_array = [int(n) for n in array]
        return num_array

    def strarr(self):
        line = input()
        array = line.split(' ')
        array[-1] = array[-1].strip('\n')
        return array


main()

Submission status: Accepted

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

ans = 1

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

prev = ''
new = []
for c in s:
    if prev != c:
        new.append(c)
    prev = c

print(len(new))

Submission status: Accepted

Solution code:
slime=int(input())
color=input()
col=list(color)
ret=list()
count=0

ret.append(col[0])
for i in range(1,slime):
  if ret[count]!=col[i]:
    ret.append(col[i])
    count=count+1

print(len(ret))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
S = input()
prev = ""
ret = 0
for s in list(S):
    if not s == prev:
        ret += 1
    prev = s
print(ret)

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(len(s)-cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

S = input()

S += "."

G = ""

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

print(len(G))

Submission status: Accepted

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

Submission status: Accepted

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

slime = 1

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

Submission status: Accepted

Solution code:
N = int(input())
S = str(input())
statement = list(S)
ans = 1
for i in range(0,N-1):
    if not statement[i] == statement[i+1]:
        ans += 1
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# this is smart N, *D = map(int, read().split())
import sys
from collections import deque

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

n = input()
s = input()

temp = ''
dq = deque()
for _ in s:
    if _ != temp:
        dq.append(_)
    temp = _
ans = len(dq)

print(ans)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    s = input()
    prev = ''
    cnt = 0
    for i in range(len(s)):
        if s[i] != prev:
            cnt += 1
            prev = s[i]
    print(cnt)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

n = int(input())
s = input()
cnt = 1

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

print(cnt)

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)

Submission status: Accepted

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

S = input()

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

print(count)

Submission status: Accepted

Solution code:
import numpy as np

n = int(input())
# s = [int(s_) for s_ in input().split()]
s = input()

c = 0
s0 = ''
for s_ in s:
    if s0 != s_:
        c += 1
        s0 = s_
      
print(c)

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()
sum=1
i=1
str=s[0]
while i<=n-1:
  if str == s[i]:
    i+=1
  else:
    str=s[i]
    sum+=1
    i+=1
    
print(sum)

Submission status: Accepted

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

count = 1
last = S[0]
for n in range(1,N):
  
  if S[n] == last:
    pass
  else:
    count += 1
    
  last = S[n]
  
print(count)

Submission status: Accepted

Solution code:
# C
N = int(input())
S = input()
check = ''
count = 0
for i in range(N):
    if check == S[i]:
        count+=1
    else:
        check = S[i]
print(N-count)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import numpy as np

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

# 1種類は確実にいる
ans = 1

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

print(ans)

Submission status: Accepted

Solution code:
num=int(input())
data=list(input())
 
count=1
for i in range(num-1):
  if data[i] is not data[i+1]:
    count+=1
print(count)

Submission status: Accepted

Solution code:
N = int(input())
s = list(input())
s_new = []

i = 0
s_new.append(s[i])
while True:
    if i + 1 >= N:
        break
    i += 1
    if s[i] != s_new[-1]:
        s_new.append(s[i])

print(len(s_new))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import numpy as np

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

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

print(ans)

Submission status: Accepted

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

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

print(c + 1)

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 = list(input())
num = 0
str1 = ""
for x in S:
    if x != str1:
        num +=1
        str1 = x
print(num)

Submission status: Accepted

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

prev = ''
counter = 0
for s in S:
    if s == prev:
        counter += 1
    prev = s
print(len(S) - counter)

Submission status: Accepted

Solution code:
N = int(input())
s = str(input())
i = 1
ps = s[0]
ans = 1
while (i<N):
    if s[i]!=ps:
        ps = s[i]
        ans+=1
    i+=1
print(ans)

Submission status: Accepted

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

ans = [a[0]]
for i in range(1,len(a)):

    if a[i] != a[i - 1]:
        ans.append(a[i])

print(len(ans))

Submission status: Accepted

Solution code:
import re
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()
count = 1
for i in range(1,len(s)):
   if s[i] != s[i-1]:
       count = count + 1
print(count)

Submission status: Accepted

Solution code:
N=int(input())
S=input()
#d=list(map(int,input().split()))

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

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

unique = set(s)
for i in unique:
    s = re.sub(i+'+',i,s)
print(len(s))

Submission status: Accepted

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

print(len(list))

Submission status: Accepted

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

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

print(n)

Submission status: Accepted

Solution code:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import bisect

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))

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

ans = 0
left = ""
for s in S:
    if left != s:
        ans += 1
        left = s
    else:
        pass
print(ans)

Submission status: Accepted

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

ans = 0
previous_s = -1
for s in S:
    if s != previous_s:
        ans += 1
    previous_s = s

print(ans)

Submission status: Accepted

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

count = 0

gr = itertools.groupby(S)
for key, group in gr:
    # print(list(group))
    count += 1
print(count)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
S = input()
postc = ''
answer = 0
for c in S:
    if c != postc:
        answer += 1
    postc = c
print(answer)

Submission status: Accepted

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

ans = 0
last = ""
for i in range(N):
    if S[i] == last:
        continue
    else:
        ans += 1
        last = S[i]
print(ans)

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

if __name__ == '__main__':

	n = int(input())
	A = input()
	B = ""
	end = ""

	for i in A:
		if end != i:
			B += i
			end = i

	print(len(B))

Submission status: Accepted

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

ans = 1

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

print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from itertools import groupby
def print_ans(input_line):
    """Test Case
    >>> print_ans("aabbbbaaca")
    5
    >>> print_ans("aaaaa")
    1
    >>> print_ans("xxzaffeeeeddfkkkkllq")
    10
    """
    print(len(list(groupby(input_line))))

if __name__ == '__main__':
    N = int(input().rstrip())
    s = input().rstrip()
    print_ans(s)

Submission status: Accepted

Solution code:
input()
s = input()
ss = set(s)

for i in ss:
    s = s.replace(i*2, i)
    a = s.replace(i*2, i)
    while s != a:
        s = a
        a = s.replace(i*2, i)

print(len(s))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
n = int(input())
s = [ord(i) for i in input()]
print(np.sum(np.diff(s)!=0)+1)

Submission status: Accepted

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

T = "_"

for s in S:
    if T[-1] == s:
        continue
    else:
        T += s

T = T[1:]
print(len(T))

Submission status: Accepted

Solution code:
def calculate(S):
    arr = list(S)

    if len(arr) == 0:
        return 0

    if len(arr) == 1:
        return 1

    N = len(arr)

    tmp = 1
    for i in range(1,N):
        if arr[i] != arr[i-1]:
            tmp = tmp + 1
    return tmp

N = input()
S = input()
res = calculate(S)
print(res)

Submission status: Accepted

Solution code:
N = int(input())
colors = list(input())
before = ""
ans = 0
for color in colors:
  if color != before:
    ans += 1
    before = color
print(ans)

Submission status: Accepted

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

res = 0
for i in range(len(S)):
    a = S[0]
    S = S[1:]
    if a == S[0:1]:
        res += 1

print(N - res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8

a = int(input())
s = input()

ans = 0
prev = ""

for i in range(0, a):
  cur = s[i]
  if cur != prev:
    ans += 1
    
  prev = cur
  
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
S = input()
s = list(S)
count = 0
for i in range(N-1):
    if s[i] == s[i+1]:
        count += 1

print(len(s)-count)

Submission status: Accepted

Solution code:
from collections import deque

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

s = deque(s)

s2 = deque(s.popleft())

for i in range(n - 1):
    if s2[len(s2)-1] == s[0]:
        s.popleft()
    else:
        s2.append(s.popleft())

print(len(s2))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
A = int(input())
slimes = input()
total = 1
for letter in range(A - 1):
  if slimes[letter] != slimes[letter + 1]:
    total += 1
print(total)

Submission status: Accepted

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

s = S[0]
lst = [s]
for v in S:
    if s != v:
        s = v
        lst.append(s)

print(len(lst))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math

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

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

print(len(list(groupby(S))))

Submission status: Accepted

Solution code:
from collections import deque

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

cnt = N
pre = S.popleft()
while len(S) > 0:    
  if pre == S[0]:
    S.popleft()
    cnt -= 1
  else:
    pre = S.popleft()
print(cnt)

Submission status: Accepted

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

print(cnt)

Submission status: Accepted

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

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

Submission status: Accepted

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

count = 0
for i in range(num-1):
  if slimes[i] == slimes[i+1]:
    count += 1

print(num - 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:
n = int(input())
s = input()
count = 1

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

print(count)

Submission status: Accepted

Solution code:
n = int(input())
s = list(input())
#print(n,s)
x = s[0]
#y = []
s2 = s.copy()
count = 0
for num,i in enumerate(s[1:n],1):
#  print(x,s2[num],num)
  if x == s2[num]:
#    y.append(s2[num])
#    print('hit')
    count += 1
  x = s2[num]
#print((y))
print(n-count)

Submission status: Accepted

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


ans = ""
check = ""
for i in range(len(S)):
  if check != S[i]:
    ans += S[i]
    check = S[i]

ans = print(len(ans))

Submission status: Accepted

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

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

print(len(s.replace('0', '')))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import groupby
def print_ans(input_line):
    """Test Case
    >>> print_ans("aabbbbaaca")
    5
    >>> print_ans("aaaaa")
    1
    >>> print_ans("xxzaffeeeeddfkkkkllq")
    10
    """
    print(len(list(groupby(input_line))))

if __name__ == '__main__':
    N = int(input())
    s = input()
    print_ans(s)

Submission status: Accepted

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

Submission status: Accepted

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

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

temp = ""
ans = 1

for x in s:
    if temp == "":
        temp = x
    if temp == x:
        continue
    else:
        temp = x
        ans += 1
    
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

latest=0
L=[]
for i in range(n):
      if s[i]!=latest:
            L.append(s[i])
            latest=s[i]
print(len(L))

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc143/tasks/abc143_c
# -*- coding: utf-8 -*-

sli_len = int(input())
sli_clr = list(str(input()))

sli_cnt = 1
for i in range(1, sli_len):
    if sli_clr[i] != sli_clr[i-1]:
        sli_cnt += 1

print(sli_cnt)

Submission status: Accepted

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

counter = 0
sub = ''
for item in a:
    if item != sub:
        counter += 1

    sub = item



print(counter)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8

N = int(input())
s = str(input())
#s = list(map(str, input().split()))
#print(s)
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())

pred = s[0]
res = 0

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

Submission status: Accepted

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

lst = []
for i in S:
    if lst == []:
        lst.append(i)
    elif lst[-1] != i:
        lst.append(i)
    else:
        continue
print(len(lst))

Submission status: Accepted

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

l = list(s)

c_color = l[0]
slimes = []
count = 0
for item in l:
    if not item == c_color:
        slimes.append(c_color)
        count += 1
        c_color = item

slimes.append(c_color)
count += 1
c_color = item

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

count = 1

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

Submission status: Accepted

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

tempchar = ""
ans = n
for c in s:
	if(tempchar == c):
		ans -= 1
	else:
		tempchar = c

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

for e in s[1:]:
    if p != e:
        p = e
        ans += 1

print(ans)

Submission status: Accepted

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

conti = True
while conti:
    try:
        conti = False
        for count, char in enumerate(s):
            if (count - 1) >= 0 and s[count] == s[count - 1]:
                s = s[:count] + s[count + 1:]
                conti = True
    except IndexError:
        pass

print(len(s))

Submission status: Accepted

Solution code:
def main():
  N = int(input())
  S = input()
  
  ans = 1
  
  for i in range(N-1):
    if S[i] != S[i+1]: ans += 1
      
  print(ans)
  
if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
n=int(input())
s=input()
point=1
i=0
j=0
cnt=1
while(j<len(s) and i<=j):
    if(s[j]==s[i]):
        j+=1
    else:
        cnt+=1
        i=j
print(cnt)

Submission status: Accepted

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

i = 1
while i < len(S):
    if S[i] == S[i-1]:
        S.pop(i)
    else:
        i += 1

print(len(S))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    S = input().rstrip() + "."
    ans = sum(i != j for i, j in zip(S, S[1:]))
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    S = input().rstrip()
    S += "."
    ans = sum(i != j for i, j in zip(S, S[1:]))
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    S = input().rstrip()
    S += "."
    ans, cur = 0, S[0]
    for s in S[1:]:
        if s != cur:
          ans += 1
          cur = s
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

List_S = list(S)
Ans = 1

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

Submission status: Accepted

Solution code:
import re
input()
s=input()
print(len(re.findall(r"(.)\1*",s)))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n=int(input())
s=list(input())
result = []
for i in range(n):
  if i==0:
    result.append(s[0])
  elif s[i-1]==s[i]:
    continue
  else:
    result.append(s[i])
print(len(result))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
s = input()
stk = []
for c in s:
    while stk and stk[-1] == c:
        stk.pop()
    stk.append(c)
print(len(stk))

Submission status: Accepted

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

i=0
while i<(len(l)-1):
    if l[i]==l[i+1]:
        l.pop(i+1)

    else:
        i=i+1

print(len(l))

Submission status: Accepted

Solution code:
N = int(input())
line=str(input())
l=list(line)
c=0
st=[0]
for i in l:
    if st[c] != i:
        st.append(i)
        c+=1
st.remove(0)
print(len(st))

Submission status: Accepted

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

Submission status: Accepted

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

new_s = ""
temp=""

for i in range(n):
  if temp != s[i]:
    new_s += s[i]
    temp=s[i]

print(len(list(new_s)))

Submission status: Accepted

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

p = None
ret = 0

for si in s:
  if si != p:
    ret += 1
  p = si

print(ret)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def p_c():
    n = int(input())
    S = input()
    bf = ""
    ans = 0
    for s in S:
        if bf != s:
            ans += 1
        bf = s
    print(ans)

p_c()

Submission status: Accepted

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

Submission status: Accepted

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

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

print(cnt)

Submission status: Accepted

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

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

tmp='0'
cnt=0
 
for i in range(N):
    if li[i]!=tmp:
        cnt+=1
        tmp=li[i]
print(cnt)

Submission status: Accepted

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

c=0

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

Submission status: Accepted

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

Submission status: Accepted

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

def solve():
    N = int(input())
    S = input()

    pre_color = S[0]
    ans = 1
    for i in range(1, N):
        color = S[i]

        if pre_color == color:
            continue
        else:
            ans += 1
            pre_color = color

    print(ans)

if __name__ == "__main__":
    solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import *

raw_input()
s = raw_input().rstrip()
print sum(1 for c, v in groupby(s))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

char_S=list(S)

answer=1


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

print(answer)