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()
ans=1
S_LENGTH=len(S)
for i in range(S_LENGTH-1):
    if S[i]==S[i+1]:
        pass
    else:
        ans+=1
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]:
        x -= 1
print(x)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a=None
count=0
roop=int(input())
li = list(input())
for i in range(roop):
  if li[i]!=a:
    count+=1
    a=li[i]
print(count)

Submission status: Accepted

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

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

Submission status: Accepted

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

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
input()
n = input()
x = list()
for i, s in enumerate(n):
  if i == 0:
    x.append(s)
    continue
  if s != x[-1]:
    x.append(s)
print(len(x))

Submission status: Accepted

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

ans = n

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

temp = s[0]
i = 1
while i < len(s):
  if s[i] == temp:
    s = s[:i] + s[i+1:]
  else:
    temp = s[i]
    i += 1
    
print(len(s))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

cnt = 0
prev = slimes.pop(0)
while slimes != []:
    curr = slimes.pop(0)
    if prev != curr:
        cnt += 1
    prev = curr

print(cnt+1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

forcuss = 0
j = 1
number = 1

while j != N:
    if S[forcuss] == S[j]:
        j = j + 1
        continue
    elif S[forcuss] != S[j]:
        number = number + 1
        forcuss = j
        j = forcuss + 1

print(number)

Submission status: Accepted

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

ans = 1

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

print(ans)

Submission status: Accepted

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

print(count)

Submission status: Accepted

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

lc = s[0]
cnt = 1
for c in s:
    if lc == c: pass
    else:
        lc = c
        cnt += 1

print(cnt)

Submission status: Accepted

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

count = 1
color = s[0]

for slime in s:
    if color != slime:
        count += 1
        color = slime

print(count)

Submission status: Accepted

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

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

        if i == N-1:
            ans += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:


def next_int():
    return int(input())

def next_ints():
    return list(map(int, input().split()))
n = next_int()
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())

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

Submission status: Accepted

Solution code:
N = int(input());S = list(input());print(len([(x,i) for i,x in enumerate(S) if i != N-1 if x != S[i+1]])+1)

Submission status: Accepted

Solution code:
def main():    
    n = int(input())
    s = input()
    ans = 0
    q2 = ''

    for i in s:
        q1 = i
        if q1 != q2:
            ans += 1
            q2 = q1
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import deque

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

    que = deque(s)
    ans = 0
    q2 = ''

    while len(que)>0:
        q1 = que.popleft()
        if q1 == q2:
            continue
        else:
            ans += 1
            q2 = q1
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#143c
N = int(input()) #N<=10**5
S = str(input())

ans = 1

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

Submission status: Accepted

Solution code:
def main():

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

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

pre=0
counter=0
for slm in d:
    if(pre != slm):
        counter +=1
    pre = slm
print(counter)

Submission status: Accepted

Solution code:
n = int(input())
s = list(input())
ans = 1
start = s[0]
if n == 1:
    print(1)
else:
    for w in s[1:]:
        if w == start:
            continue
        else:
            ans += 1
            start = w
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
num = int(input())
letters = input()
count = 0
color = ''
for i in letters:
  if color != i:
    count += 1
  color = i
print(count)

Submission status: Accepted

Solution code:
def solve(string):
    n, s = string.split()
    return str(int(n) - sum([1 for d1, d2 in zip(s, s[1:]) if d1 == d2]))


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))

Submission status: Accepted

Solution code:
from itertools import groupby


def solve(string):
    n, s = string.split()
    return str(len(list(groupby(s))))


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))

Submission status: Accepted

Solution code:
N = int(input())
S = input()
ans = 1
for i in range(N):
  if i <= len(S)-2:
    if S[i] !=S[i+1]:
      ans = 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())
S = input()
L = len(S)
ans = 1
for i in range(L):
    if i==0:
        continue
    if S[i] == S[i-1]:
        continue
    else:
        ans+=1
print(ans)

Submission status: Accepted

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

ans = 1

for i in range(0, N-1, 1):
    if lst_S[i] != lst_S[i+1]:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8

n = int(input())

d = input()

s = []
for i in range(n):
    if ((len(s) > 0 and d[i] != s[len(s)-1]) or (len(s) == 0)):
        s.append(d[i])
print(len(s))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import groupby 

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

print(sum([ 1 for x in groupby(S)]))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N=int(input())
slimes = []
all_slime=input()
slimes.append(all_slime[0])
lastColor = all_slime[0]
for i in range(1,N):
    new_slime = all_slime[i]
    if not lastColor == new_slime:
        slimes.append(new_slime)
    lastColor=new_slime
print(len(slimes))

Submission status: Accepted

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

N=int(input())
S = input().split()
S = list(S[0])
ans=[]
ans.append(S[0])
for i in range(1,N):
    if ans[-1]!=S[i]:
        ans.append(S[i])

print(len(ans))

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:
# coding: utf-8
# Your code here!

from collections import deque

N = int(input())
S = deque(input())
A = []
ctr = 0

for i in range(N):
    tmp = S.popleft()
    if A == [] or A[-1] != tmp:
        ctr += 1
    A.append(tmp)
print(ctr)

Submission status: Accepted

Solution code:
n = int(input())
s = input()
cnt = 0
a = None

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

Submission status: Accepted

Solution code:
X=int(input())
Y = input()
r=""
a=0
for i in Y:
  if r!=i:
    r=i
    a+=1
print(a)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:

N = int(input())
foo = ""
ans = 0
for i in input():
    if foo != i:
        ans += 1
    foo = i
print(ans)

Submission status: Accepted

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

slime=slime_list[0]
count=1
for s in slime_list:
 if (s!=slime):
  count+=1
  slime=s
 else:
  continue

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(c)

Submission status: Accepted

Solution code:
row = int(input())
data = list(str(input()))

def checker(big,end,index):
	if big == end:
		return 1
	else :
		return 2

resp = []
for var in range(1,row):
	if checker(data[var-1],data[var],var) == 1:
		resp.append(var)
	else:
		pass

resp.reverse()
#逆順にして長さを変化しなくする
for deldex in resp:
	del data[deldex]
	

print(len(data))

Submission status: Accepted

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

for i, str in enumerate(S):
  while True:
    if i != len(S)-1:
      next = S[i+1]
      if str == next:
        S.pop(i+1)
      else:
        break
    else:
      break
print(len(S))

Submission status: Accepted

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

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 = input()
ans = 0
prev = ""

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
S=input()
ANS=list('')
BF = ''
for s in S:
  if BF != s:
    ANS.append(s)
    BF = s
print(len(ANS))

Submission status: Accepted

Solution code:
# print('input >>')
N = input()
S = input()

ans = 1
left = S[0]
for s in S:
    if not s == left:
        ans += 1
        left = s

# print('----------output----------')
print(ans)

Submission status: Accepted

Solution code:
def remove_duplicate(s):
    out=s[0]
    for i in range(1,len(s)):
        if s[i]!=out[-1]:
            out+=s[i]
    return len(out)
n = int(input())
# A= [int(c) for c in input().strip().split(' ')]
s = input().strip()
print(remove_duplicate(s))

Submission status: Accepted

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

stert = str_list[0]
count = 1
for i in range(1,n):
  if stert == str_list[i]:
    pass
  else:
    stert = str_list[i]
    count+=1
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
n=input()
s=raw_input()
ans=0
curr=''
for i in s:
    if i!=curr:
        ans+=1
        curr=i
print ans

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
MOD = 1000000007
def POW(x, y): return pow(x, y, MOD)
def INV(x, m=MOD): return pow(x, m - 2, m)
def DIV(x, y, m=MOD): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())

N=II()
s=input()
last = ""
cnt = 0
for i in range(N):
    if last != s[i]:
        cnt += 1
        last = s[i]

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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:
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    S = list(input()[:-1])

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
_ = int(input())
s = list(input())
l = []
w = ''
for i in s:
    if w == i:
        pass
    else:
        l.append(i)
        w = i
print(len(l))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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 = input()
S = list(input())
count = 1
current = S[0]
for char in S:
    if char != current:
        count += 1
    current = char
print(count)

Submission status: Accepted

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

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

Submission status: Accepted

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

ans = 1

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

print(ans)

Submission status: Accepted

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

prev = S[0]
c = 1
for s in S :
    if (prev != s) :
        prev = s
        c += 1

print(c)

Submission status: Accepted

Solution code:
N = int(input())
S = input()
pre = 'Z'
ans = 0
for c in S:
    if c != pre:
        ans += 1
    pre = c

print(ans)

Submission status: Accepted

Solution code:
#import sys
#input = sys.stdin.readline
 
N = int(input())
s= list(input())
 
s0 = s.pop()
 
cnt = 1
 
while s:
    s1 = s.pop()
    if s1!=s0:
        cnt += 1
        s0 = s1
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    S = input()
    
    ans = 0
    kako = ""
    for i,val in enumerate(S):
        if i == 0:
            ans += 1
            kako = val
            continue
        
        if val != kako:
            ans += 1
            kako = val
    
    print(ans)
    
if __name__ == "__main__":
	main()

Submission status: Accepted

Solution code:
# coding: utf-8

import sys
import math
import collections
import itertools
from inspect import currentframe
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def MI() : return map(int, input().split())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def chkprint(*args) : names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}; print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

N = I()
S = input()

ans = 0

tmp = "#"
for s in S:
    if s != tmp:
        ans += 1
        tmp = s

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:
n = int(input())
s_word = list(input())
start_w = s_word[0]
goal_num = 0
for i in range(n-1):
    if s_word[i+1] != start_w:
        start_w = s_word[i+1]
        goal_num += 1
goal_num +=1
print(goal_num)

Submission status: Accepted

Solution code:
_=input()
s=input()
t=''
a=1
for i in range(len(s)-1):
  if s[i]!=s[i+1]:
    a+=1
print(a)

Submission status: Accepted

Solution code:
N = int(input())
Slime = list(input())
check = Slime[0]
res = 0

for i in range(N-1):
	if Slime[i+1] != check:
		check = Slime[i+1]
		res += 1
res += 1

print(res)

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
print(count+1)

Submission status: Accepted

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

n = int(input())
s = input()
print(solve(n, s))

Submission status: Accepted

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

Submission status: Accepted

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

count = 0
tmp = ""

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

Submission status: Accepted

Solution code:
n=int(input())
a=input().strip()
x=""
x+=a[0]
for i in range(1,n):
  if a[i]!=a[i-1]:
    x+=a[i]
print(len(x))

Submission status: Accepted

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

ans = 0
prev = ''

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

Submission status: Accepted

Solution code:
N = int(input())
S = input()
cnt = 1
for ind,s in enumerate(S[:-1]):
    if(S[ind+1]!=s):
        cnt += 1
print(cnt)

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

pre_color = list(S)[0]
count = 1
for i in list(S):
  if pre_color != i:
    pre_color = i
    count += 1

print(count)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

p = ''
r = 0
for i in range(N):
    if p != S[i]:
        r += 1
        p = S[i]
print(r)

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
else:
  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 = list(input())
sum = 0
prev = "0"
for i in S:
  if prev != i:
    sum += 1
  prev = i
print(sum)

Submission status: Accepted

Solution code:
n = int(input())
s = list(input())
count = 1
s0 = s.pop(0)
for i in s:
    if s0 != i:
        count += 1
        s0 = i

print(count)

Submission status: Accepted

Solution code:
n=int(input())
S=str(input())
s=list(S)
i=1
while True:
    if i >= n:
        break
    if s[i-1]==s[i]:
        s.pop(i)
        n -= 1
    else:
        i +=1

print(len(s))

Submission status: Accepted

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

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

print(res)

Submission status: Accepted

Solution code:
n=int(input())
S=str(input())
s=list(S)
i=1
while True:
    if n ==1 or n==0:
        break
    if s[i-1]==s[i]:
        s.pop(i)
        n -= 1
    else:
        i +=1
    if i >= n:
        break
print(len(s))

Submission status: Accepted

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

p=''
ans=0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

ans = 1
sav = S[0]
for index in range(1, int(N)):
    if S[index] != sav:
        sav = S[index]
        ans += 1

print(ans)

Submission status: Accepted

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

ans = 0
sav = ""
for index in range(int(N)):
    if sav == "":
        sav = S[index]
        ans += 1
    elif S[index] != sav:
        sav = S[index]
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
n = int(input())

d = input()

res = 1

jud = d[0]

for i in d:
	if i!=jud:
		res += 1
	jud = i

print(res)

Submission status: Accepted

Solution code:
N=int(input())
s=input()
s_list=list(s)
import itertools as itl
list2=[k for k, v in itl.groupby(s_list)]
print(len(list2))

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(raw_input())
S = raw_input()
A = ['']
for i in range(N):
  if A[-1] != S[i]:
    A.append(S[i])
print(len(A) - 1)

Submission status: Accepted

Solution code:
#coding:utf-8

n = int(input())
s = list(input())
# 最初の1種類はカウントしておく
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()

ans = N

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

Submission status: Accepted

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

Submission status: Accepted

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

last=None

for C in COLOR:
    if C==last:
        N-=1
    last=C

print(N)

Submission status: Accepted

Solution code:
gomi=input()
slime=[0]
for i in list(input()):
  
  if i != slime[-1]:
  	slime.append(i)
print(len(slime)-1)

Submission status: Accepted

Solution code:
N = int(input())
l = input()
cnt = 1
cur = l[0]

for i in range(1,N):
  if l[i]!=cur:
    cnt+=1
    cur = l[i]

print(cnt)

Submission status: Accepted

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

count = 0
prev = ''

for l in s:
    if l != prev:
        prev = l
        count += 1
    
print(count)

Submission status: Accepted

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

st = []
for c in s:
    if st:
        bc = st.pop()
        if bc == c:
            st.append(c)
        else:
            st.append(bc)
            st.append(c)
    else:
        st.append(c)

print(len(st))
# print(st)

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:
number= int(input())
color =input()

change_times=0
color_before=''


for index in range(number):
	if index == 0:
		color_before= color[index]
	elif color[index] == color_before:
		continue
	else:
		change_times=change_times+1
		color_before= color[index]
		
print(change_times+1)

Submission status: Accepted

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

a = list()
a.append('qqq')

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

Submission status: Accepted

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

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

print(n-an)

Submission status: Accepted

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

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]:
        ans += 1
    pre = s[i]

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:
# ABC143 C - Slimes

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

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

print(sum + 1)

Submission status: Accepted

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

ans = 0

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

print(ans + 1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
S = input()
s = S[0]

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

Submission status: Accepted

Solution code:
#143
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:
n=int(input())
s=input()
s=list(s)
T=[]
tmp=0
for i in range(len(s)):
    if s[i]!=tmp:
        T.append(s[i])
        tmp=s[i]
print(len(T))

Submission status: Accepted

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

Submission status: Accepted

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

S_n_1 = S[0]
resList = list()
for i in range(1, N):
    S_n = S[i]
    if S_n != S_n_1:
        resList.append(S_n_1)
    S_n_1 = S_n
resList.append(S_n_1)
print(len(resList))