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:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
''' 
------------------------
author : iiou16
------------------------
'''

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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
from collections import deque
def input():
    return sys.stdin.readline()[:-1]
# input
_ = int(input())
S = input()
s = deque([i for i in S])

count = 1
last = s.popleft()
for i in range(_-1):
    poped = s.popleft()
    if last == poped:
        continue
    else:
        count += 1
        last = poped
print(count)

Submission status: Accepted

Solution code:
from itertools import zip_longest
n = int(input())
s = input()
test_list = list(s)
res = [i for i, j in zip_longest(test_list, test_list[1:]) if i != j]
print(len(res))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
M = list(input())
oi =1
m = M[0]
for i in range(1,len(M)):
    if m == M[i]:
      pass
    else:
      m = M[i]
      oi = oi + 1    
    
print(oi)

Submission status: Accepted

Solution code:
n = int(input())
S = input()
buff = ''
ans = []
for s in S:
    if s != buff:
        ans.append(s)
        buff = s
print(len(ans))

Submission status: Accepted

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

import sys

n = int(sys.stdin.readline().strip())
s = sys.stdin.readline().strip()

cnt = 0
prev=""
for c in s:
    if c==prev: continue
    cnt += 1
    prev = c
#    
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import groupby

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

print(sum(1 for k, _ in groupby(S)))

Submission status: Accepted

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

result = 1
prev = S[0]
for c in S[1:]:
    if prev != c:
        result += 1
    prev = c

print(result)

Submission status: Accepted

Solution code:
N = int(input())
d = [x for x in input()]
#print(d)

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

Submission status: Accepted

Solution code:
N = int(input())
S = input()
import re
def nchars(s, n):
    """文字列 s に、同じ文字が n 個以上連続している部分文字列を見つける
    """
    assert n > 0
    reg = re.compile("(.)\\1{%d,}" % (n - 1))  # カンマを取ると n 個ちょうどになる
    while True:
        m = reg.search(s)
        if not m:
            break
        yield m.group(0)
        s = s[m.end():]

print(len(list(nchars(S, 1))))

Submission status: Accepted

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

print(n-same)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
s = input()
b = ''
c = 0
for i in s:
  if b == i:
    b = i
    pass
  else:
    c += 1
    b = i
print(c)

Submission status: Accepted

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

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

print(sum)

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
##################################################################

if __name__ == "__main__":
    Input = [input() for i in range(2)]
    N = int(Input[0])
    #S = list(map(int,Input[1].split()))
    S = str(Input[1])
    c = 1
    for i in range(1,N):
        if S[i] != S[i-1]:
            c += 1
        else:
            pass
    print(c)

Submission status: Accepted

Solution code:
def A():
    temp = [int(i) for i in input().split()]
    print(max(0, temp[0]-2*temp[1]))

def B():
    N = int(input())
    T = [int(i) for i in input().split()]
    s = 0
    for i in range(N):
        for j in range(i):
            s += T[i]*T[j]
    print(s)

def C():
    N = int(input())
    S = input()
    if N == 1:
        print(1)
    else:
        ans = 1
        cur_c = S[0]
        for c in S:
            if c != cur_c:
                ans += 1
                cur_c = c
        
        print(ans)

C()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
#ls = map(str, input().split())
ls = input()
vocab = set(list(ls))

for v in vocab:
    vv = True
    while vv:
        if v+v in ls:
            ls = ls.replace(v+v, v)
        else:
            vv = False

print(len(ls))

Submission status: Accepted

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

ans = 0
n = 1

while n<N:
  if S[n]==S[n-1]:
    ans +=1
    n +=1
  else:
    n+=1

print(N-ans)

Submission status: Accepted

Solution code:
N = input()
S = list(input())
ans = 1
hako = S[0]

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

Submission status: Accepted

Solution code:
"""
N=int(input())
L=[int(x) for x in input().split()]
L.sort()
count=0


for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            if L[k]>=L[i]+L[j]:
                break
            count+=1
            
print(count)
"""
N=int(input())
S=input()
result=N
for i in range(N):
    if i+1==N:
        break
    
    if S[i]==S[i+1]:
        result-=1

print(result)

Submission status: Accepted

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

flag=True


while(flag):
  flag=False
  c_new=''
  for i in range(len(c)-1):
    if c[i]==c[i+1]:
      flag=True
      #del c[i-minus]
      #minus+=1
    else:
      c_new+=c[i]
  c_new+=c[len(c)-1]
  c=c_new
print(len(c))

Submission status: Accepted

Solution code:
n=int(input())
s=input()
from itertools import*
g=[len(list(v))for k,v in groupby(s)]
print(len(g))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())
s = input()
dict = {}
for i,j in zip(range(0, n), s):
    dict[i] = j

for i in range(0, n - 1):
    if dict[i] == dict[i+1]:
        del dict[i]
        n -= 1
    else:
        continue
print(len(dict))

Submission status: Accepted

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

i = 0
while len(s) - 1 >= i + 1:
    while s[i] == s[i + 1]:
        s.pop(i)
        if i + 2 > len(s):
            break
    i += 1
        
print(len(s))

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    S = input()
    prev = "-"
    res = 0
    for c in S:
        if prev != c:
            res += 1
            prev = c
    print(res)
main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

n = int(sys.stdin.readline())
S = list(sys.stdin.readline().rstrip())

for i in range(1, n):
    if(S[i-1] ==S[i]):
        S[i-1]=""
S = ''.join(S)
#print(S)
print(len(S))

Submission status: Accepted

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

answer = list()
dp = S[0]

answer.append(S[0])
for i, s in enumerate(S):
  if(dp != s):
    answer.append(s)
    dp = s
    
    
print(len(answer))

Submission status: Accepted

Solution code:
def calc(N, S):
    r = 0
    c = ''
    for i in range(N):
        if c != S[i]:
            r += 1
            c = S[i]
    return r


N = int(input())
S = input()
print(calc(N, S))

Submission status: Accepted

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

counter = 1

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 1
i = 0
j = 0
while i < (N-1):
  j += 1
  while S[i] == S[j]:
    if j == N-1: 
      print(ans)
      exit()
    else:
      j += 1
  ans += 1
  i = j
  
print(ans)

Submission status: Accepted

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

ans = 1

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

Submission status: Accepted

Solution code:
import itertools

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


def solve():
    cnt = 0
    for key in itertools.groupby(S):
        cnt += 1

    return cnt


print(solve())

Submission status: Accepted

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

r = ds[0]
for d in ds[1:]:
  if r[-1] != d:
    r += d

print(len(r))

Submission status: Accepted

Solution code:
_ = input()
S = input()
k = 1
for b, a in zip(S[:-1], S[1:]):
    if b!=a:
        k += 1
print(k)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

count = 0
for i in reversed(range(len(s)-1)):
    if s[i+1] == s[i]:
        count += 1

print(len(s)-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 = ans
  else:
    ans = ans + 1
print(ans)

Submission status: Accepted

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

print(N - count)

Submission status: Accepted

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

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


c = len(arr)
print(c)

Submission status: Accepted

Solution code:
n=int(input())
a=input()
i=0
b=[a[0]]
j=0
p=0
while(i<len(a)):
    if(b[-1]!=a[i]):
        b.append(a[i])
    i=i+1
print(len(b))

Submission status: Accepted

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

last = []

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

print(len(last))

Submission status: Accepted

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

a=""
result=0
for s in S:
    if a!=s:
        result +=1
    a=s

print(result)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from collections import defaultdict, deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys
import random
import itertools
import math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt


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


def LF(): return list(map(float, input().split()))


def LI_(): return list(map(lambda x: int(x)-1, input().split()))


def II(): return int(input())


def IF(): return float(input())


def LS(): return list(map(list, input().split()))


def S(): return list(input().rstrip())


def IR(n): return [II() for _ in range(n)]


def LIR(n): return [LI() for _ in range(n)]


def FR(n): return [IF() for _ in range(n)]


def LFR(n): return [LI() for _ in range(n)]


def LIR_(n): return [LI_() for _ in range(n)]


def SR(n): return [S() for _ in range(n)]


def LSR(n): return [LS() for _ in range(n)]


def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x % y)


def my_index_multi(l, x):
    return [i for i, _x in enumerate(l) if _x == x]


def sosu(x):
    for i in range(2, int(sqrt(x)+1)):
        if x % i == 0:
            return False
    return True


mod = 1000000007
inf = float('INF')


def A():
    A, B = LI()
    ans = A-2*B
    if ans > 0:
        print(ans)
    else:
        print(0)
    return

# B


def B():
    N = II()
    d = LI()
    ans = 0
    for i in range(N):
        for x in range(i+1, N):
            ans += d[i]*d[x]
    print(ans)

    return

# C


def C():
    N = II()
    S = input()
    c=0
    count=0
    for i in S:
        if i!=c:
            count+=1
        c=i
    print(count-1)

    return

# D


def D():
    A, B = map(int, input().split())
    g = gcd(A, B)
    # go = g
    # myset = set([1])
    sq = int(sqrt(g)) + 2
    ans = 1

    for i in range(2, sq):
        if g % i == 0:
            ans += 1
        while g % i == 0:
            g /= i

            # myset.add(i)
        if g == 1:
            break
        if i == sq - 1:
            # myset.add(go)
            ans += 1

    print(ans)

    return

# E


def E():
    N, M = LI()
    bit_max = 1 << N
    dp = [[inf for i in range(bit_max)] for j in range(M+1)]
    dp[0][0] = 0

    for i in range(M):
        a, b = LI()

        c = LI()
        bit = 0

        for d in c:
            bit |= 1 << (d-1)

        for w in range(bit_max):

            t = w | bit
            cost = dp[i][w] + a

            dp[i+1][t] = min(dp[i+1][t], cost)

            dp[i+1][w] = min(dp[i][w], dp[i+1][w])

    print(-1) if dp[-1][-1] == inf else print(dp[-1][-1])

    return

# F


def F():
    N, M = LI()

    value = [0] * M
    power = [0] * M
    for i in range(M):
        a, b = LI()
        value[i] = a
        c = LI()
        L = ['0'] * N
        for k in c:
            L[k - 1] = '1'
        bint = ''.join(L)
        power[i] = int(bint, 2)
    bint = ''.join(list(['1'] * N))
    dp = [inf] * (int(bint, 2)+1)
    t = 0
    cost = 0

    dp[0] = 0
    for s in range(int(bint, 2) + 1):
        for i in range(M):
            t = s | power[i]
            cost = dp[s] + value[i]
            dp[t] = min(dp[t], cost)
    print(-1) if(dp[-1] == inf) else print(dp[-1])

    return

    # you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")


def solution(S):
    # write your code in Python 3.6
    import math

    vowels = "AIUEO"
    count = 0
    consonants = 0
    newC = []
    newV = []

    for i in S[:-1]:
        if i in vowels:
            count += 1
            newV.append(i)
        else:
            consonants += 1
            newC.append(i)

    if consonants < count or consonants - 2 > count:
        return 0

    a = math.factorial(len(set(newC))) * math.factorial(len(set(newV)))
    return a

    pass


# Solve
if __name__ == '__main__':
    C()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

res = 0
before = None
for a in s:
  if a != before:
    res += 1 
  before = a

print(res)

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

Submission status: Accepted

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

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

count = 0
mem = str()
for s in S:
    if mem == s:
        continue
    else:
        count += 1
        mem = s

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
S = input()
seen = []
tot = N
for char in S:
    if not seen:
        seen.append(char)
    elif char == seen[-1]:
        tot -= 1
        seen.append(char)
    else:
        seen.append(char)
print(tot)

Submission status: Accepted

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

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

Submission status: Accepted

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

letter = ''
for s in S:
    if letter[-1:] != s:
        letter += s
print(len(letter))

Submission status: Accepted

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

#print(N)
#print(c_list)
c_list_org = c_list

for c in range(len(c_list_org)):
    #print(c, c_list_org, c_list)
    if c >= len(c_list)-1:
        break
    if c_list[c] == c_list[c+1]:
        c_list[c] = "del"

#print(c_list)
c_list = [c for c in c_list if c != "del"]
#print(c_list)
print(len(c_list))

Submission status: Accepted

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

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()+'Q'
c = 0
for k in range(N):
	if S[k] != S[k+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 = cnt + 1

print(cnt)

Submission status: Accepted

Solution code:
N=int(input())
S=list(input())
ret=0
s_pre=""


for s in S:
  
  if s_pre!=s:
    ret+=1
  s_pre=s
print(ret)

Submission status: Accepted

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

color = []
for i in range(len(S)):
    color.append(S[i])
lst = []

for i in range(N-1,-1,-1):
    if i<=N-2:
        if color[i+1]==color[i]:
            color.pop(i+1)


print(len(color))

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

Submission status: Accepted

Solution code:
n = int(input())
s = input()
i = 0
c = s[0]
ans = 1
while True:
  if c != s[i]:
    ans += 1
    c = s[i]
  i += 1
  if i == n:
    break 
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import numpy as np

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

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

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

result = 0
pre = None

for x in S:
    if pre is None or pre != x:
        result += 1
    pre = x

print(result)

Submission status: Accepted

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

# 最初の文字はあらかじめ数えておく
count=1

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

Submission status: Accepted

Solution code:
n = int(input())

s = list(input())

checkS = ''
result = 0

for i in s:

   if checkS != i:
      result += 1
   
   checkS = i

print(str(result))

Submission status: Accepted

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

c=list()

c.append(s[0])

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

Submission status: Accepted

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


while True:
    temp_s = []
    prev_color = ""
    isFusion = False
    for i in range(len(s)):
        if s[i] == prev_color:
            continue
        else:
            temp_s.append(s[i])
            prev_color = s[i]
    s = temp_s
    if not isFusion:
        break
print(len(s))

Submission status: Accepted

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

    count = 1
    prev = s[0]

    for i in range(1, n):
        if prev == s[i]:
            continue
        count += 1
        prev = s[i]

    print(count)


if __name__ == '__main__':
    c()

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

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

l = len(S)

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

print(l)

Submission status: Accepted

Solution code:
import re

def C():
    n = input()
    s = input()
    ss = re.sub(r"(.)\1{1,}",r"\1",s)
    print(len(ss))

if __name__ == '__main__':
    C()

Submission status: Accepted

Solution code:

from sys import stdin

n = int(stdin.readline().rstrip())
s = str(stdin.readline().rstrip())
a = 1#何個目
ans = s[0]
while a < n:
    if s[a-1] == s[a]:
        pass
        a += 1
    else:
        ans += s[a]
        a += 1

print(len(ans))

Submission status: Accepted

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

count = 0
frag = False
pre = s[0]
for i in range(1, len(s)):
    if s[i-1] != s[i]:
        count += 1
print(count+1)

Submission status: Accepted

Solution code:
N=int(input())
S=list(input())
s=S.copy()
n=0
for i in range(N-1):
  if S[i]==S[i+1]:
    del s[i+1-n]
    n+=1
print(len(s))

Submission status: Accepted

Solution code:
N = int(input())
S = str(input())
flag = False
count = 1
for a in range(len(S)-1):
    if S[a] == S[a+1]:
        flag = True
    else:
        flag = False
    
    if flag == False:
        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 = ans+1
print(ans+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
s = input()
c = [0] * len(s)
o = s[0]
ans = []
for i in range(1, len(s)):
    if s[i] == o:
        c[i] = 1
    else:
        o = s[i]
for i in range(len(s)):
    if c[i] == 0:
        ans.append(s[i])
print(len("".join(ans)))

Submission status: Accepted

Solution code:
n = int(input())
s = str(input())
count = 1
for i in range(n):
    try:
        if s[i] != s[i+1]:
            count += 1
    except IndexError:
        break
print(count)

Submission status: Accepted

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

print(len(a))

Submission status: Accepted

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

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

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

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

Submission status: Accepted

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

i = 1
t = S[0]
for c in S:
    if c != t:
        i += 1
    t = c
print(i)

Submission status: Accepted

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

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

Submission status: Accepted

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

temp = None
count = 0

for slime in slimes:
  if slime != temp:
    count += 1
  temp = slime

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

num = 1
for i in range(1,N):
	if i == 0:
		color.append(S[0])
	else:
		if S[i] == S[i-1]:
			continue
		else:
			num +=1
print(num)

Submission status: Accepted

Solution code:

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

before = ""
cnt = 0
for s in S:
    if s == before:
        pass
    else:
        cnt += 1
    before = s

print(cnt)

Submission status: Accepted

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

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

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

# output
print(ans + 1)

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=list(str(input()))
t=[s[0]]
for i in range(n-1):
    if s[i] == s[i+1]:
        pass
    else:
        t.append(s[i+1])
print(len(t))

Submission status: Accepted

Solution code:
n = input()
a_L = input()
a_L = [val for val in a_L ]

from itertools import groupby
counter = 0

for key, value in groupby(a_L):
    counter += 1

print(counter)

Submission status: Accepted

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

for i in s:
    if tmp != i:
        ans += 1
    tmp = i

print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
def main():
    n = int(input())
    s = input()
    ans = 1
    start = 0
    end = 0
    for i in range(1, len(s)):
        if s[i] != s[start]:
            ans += 1
            start = i
    print(ans)
if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

print(len(R))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = input()
s = input()
result = ""
for i, color in enumerate(s):
    if i == 0 or (i > 0 and color != s[i - 1]):
        result += str(color)
print(len(result))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = [S[0]]

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

Submission status: Accepted

Solution code:
def main():
  _ = raw_input()
  slimes = raw_input()
  result = 0
  prev = None
  for color in slimes:
    if prev == None:
      prev = color
      continue
    if color != prev:
      result += 1
      prev = color
  print(result + 1)
     

main()

Submission status: Accepted

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

Submission status: Accepted

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

current = ''
for i in range(n):
    if s[i] != current:
        after_fusion.append(s[i])
        current = s[i]

print(len(after_fusion))

Submission status: Accepted

Solution code:
# coding: utf-8
# ABC143 C

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

res = [s.pop()]
while len(s) > 0:
    tmp = s.pop()
    if tmp != res[-1]:
        res.append(tmp)

print(len(res))