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 = N

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

print(Ans)

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

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

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

print(count)

Submission status: Accepted

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

ans = 1

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

print(ans)

Submission status: Accepted

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

mae = S[0]
ans = 1

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

print(ans)

Submission status: Accepted

Solution code:
import sys

def solve(n, s):
    pre = ""
    ans = n
    for s_i in s:
        if s_i == pre:
            ans -= 1
        pre = s_i

    print(ans)

if __name__ == '__main__':
    n = int(sys.stdin.readline().strip())
    s = sys.stdin.readline().strip()
    solve(n, s)

Submission status: Accepted

Solution code:
n = int(input())
s = input()
a = ""
mae = ""
for i in s:
    if(mae != i):
        mae = i
        a = a + i
print(len(a))

Submission status: Accepted

Solution code:
N = int(input())
S = input()
ans = 0
f = ''
for i in S:
    if i != f:
        f = i
        ans += 1
print(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())
S = input()

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

ans = 1

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

print(int(ans))

Submission status: Accepted

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

res = 0
i = 0
while i < N:
    j = 1
    while i + j < N and S[i] == S[i + j]:
        j += 1
    i += j
    res += 1
print(res)

Submission status: Accepted

Solution code:
N = int(input())

S = input()

ans = 1

for i in range(N-1):

	if S[i] != S[i+1]:
		ans += 1

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
s = input()
a = 1 + sum([True if i != j else False for i, j in zip(s[:-1], s[1:])])
print(a)

Submission status: Accepted

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

tmp = ''
ans = ''
for i, val in enumerate(S):
    if i != 0:
        if tmp != val:
            ans += val
        tmp = val
    else:
        tmp = val
        ans += val
print(len(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from itertools import groupby

N = int(input())
S = input()
L = []

for i in range(N):
  L.append(S[i])

sum = 0
for key, value in groupby(L):
    sum += 1
print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
s = input()
result = 0
cont_col = ""
for si in s:
    if cont_col != si:
        result += 1
        cont_col = si
print(result)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
from collections import deque
args = sys.argv
if len(args) == 2:
  from IPython import embed
  em = True
else:
  em = False
input = sys.stdin.readline
N = int(input())
Ss = list(input())
if em: sys.stdin = open('/dev/tty')
ans = []
for S in Ss:
  if ans == []:
    ans.append(S)
  elif ans[-1] == S or S == '\n':
    continue
  else:
    ans.append(S)
print(len(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    string = input()

    ans = 0
    previous_s = ''
    for s in string:
        if s != previous_s:
            ans += 1
        previous_s = s
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

counter = 1

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

Submission status: Accepted

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

slist = []
mys = S[0]

for i in range(1,len(S)):
    if mys != S[i]:
        slist += [mys]
        mys = S[i]
    else:
        continue
    
print(len(slist) + 1)

Submission status: Accepted

Solution code:
import sys


input = sys.stdin.readline


def main():
    n = int(input())
    s = input().strip()
    hoge = 1
    prev = s[0]
    for i in s[1:]:
        if prev == i:
            continue
        hoge += 1
        prev = i
    print(hoge)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from math import sqrt
import sys
from collections import defaultdict
#input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))

N = int(input())
S = input()
x = "*"
ans = 0
for s in S:
    if s != x:
        ans += 1
        x = s
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import glob



# 問題ごとのディレクトリのトップからの相対パス
REL_PATH = 'ABC\\143\\C'

# テスト用ファイル置き場のトップ
TOP_PATH = 'C:\\AtCoder'

class Common:

    problem = []
    index = 0

    def __init__(self, rel_path):
        self.rel_path = rel_path

    def initialize(self, path):
        file = open(path)
        self.problem = file.readlines()
        self.index = 0
        return

    def input_data(self):
        try:
            IS_TEST
            self.index += 1
            return self.problem[self.index-1]

        except NameError:
            return input()

    def resolve(self):
        pass

    def exec_resolve(self):
        try:
            IS_TEST
            for path in glob.glob(TOP_PATH + '\\' + self.rel_path + '/*.txt'):
                print("Test: " + path)
                self.initialize(path)
                self.resolve()
                print("\n\n")
        except NameError:
            self.resolve()


class C(Common):

    def resolve(self):
        N = int(self.input_data())
        S = self.input_data()

        slimes = list(S)

        tmp = ""
        result = 0

        for slime in slimes:
            if tmp == slime:
                continue
            else:
                result += 1
                tmp = slime

        print(str(result))

solver = C(REL_PATH)
solver.exec_resolve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

print(num)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
s = input()
ns = ''
pre = ''
for i in s:
    if i!=pre:
        ns += i
    pre = i
print(len(ns))

Submission status: Accepted

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

cnt=1
a = S[0]
for s in S[1:]:
  if s != a:
    cnt += 1
  a = s

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())
s_list = list(input())
temp_sum = 0
prev_s = s_list[0]
for i in range(1,n):
    if s_list[i] == s_list[i-1]:
        temp_sum += 1
print(n-temp_sum)

Submission status: Accepted

Solution code:
n = int(input())
s = input()
cnt = 1
if n == 1:
    print(cnt)
else:
    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()
cnt=1

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

Submission status: Accepted

Solution code:
N = int(input())
s = list(input())
now = "!"
sum_ = 0
for i in range(N):
    if now != s[i]:
        sum_ += 1
        now = s[i]
print(sum_)

Submission status: Accepted

Solution code:
N = int(input())
S = input()
ans = 0
prev = "A"
for c in S:
    if c != prev:
        ans += 1
        prev = c
        
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
s = input()
a = []
ps = ""
for _s in s:
    if ps != _s:
        a.append(_s)
        ps = _s
print(len(a))

Submission status: Accepted

Solution code:
from itertools import groupby

input()
print(sum(1 for _ in groupby(input())))

Submission status: Accepted

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

count = 1
s = S[0]

i = 1
while i < len(S):
    if s != S[i]:
        count += 1
        s = S[i]
    i += 1

print(count)

Submission status: Accepted

Solution code:
def solve():
    n = int(input())
    s = list(input())
    l = n+0
    while True:
        for i in range(l-1)[::-1]:
            if s[i] == s[i+1]:
                s.pop(i)
                l-=1
        if n == l:
            break
        n = l
    print(l)

if __name__ == '__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

prev = ' '
ans = 0
for c in S:
    if c != prev:
       ans += 1
       prev = c
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
input()
s = input()
if len(s) == 1:
    print(1)
else:
    ans = len(s)
    cur_char = s[0]
    cur_counter = 1
    for char in s[1:]:
        if cur_char == char:
            cur_counter +=1
        else:
            ans -= cur_counter -1 
            cur_char = char
            cur_counter = 1
    ans -= cur_counter -1
    print(ans)

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

    lastC = None
    n = 0

    for c in S:
        if lastC != c:
            lastC = c
            n += 1

    print(n)
    


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
s = input()
before = ''
new = ''
for c in s:
    if before != c:
        new += c
        before = c
print(len(new))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
char_list = list(input())
result_list = []

count = 0
pre_char = ''
for target in char_list:
    if (target != pre_char):
        count += 1
        pre_char = target

print(count)

Submission status: Accepted

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

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

after = []
last = "zz"
for v in c:
    if v != last:
        after.append(v)
    last = v

print(len(after) )

Submission status: Accepted

Solution code:
def main():
    n=int(input())
    c=input()
    ans = 0
    tmp=c[0]
    for i in c[1:]:
        if tmp != i:
            ans += 1
            tmp = i
    if tmp == c[-1]:
        print(ans+1)
    else:
        print(ans)
if __name__ == '__main__':
    main()

Submission status: Accepted

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


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

Submission status: Accepted

Solution code:
input()
s = input()
res = 0
before = None
for c in s:
  if (c == before):
    pass
  else:
    res += 1
  before = c
print(res)

Submission status: Accepted

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

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

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

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

print(c)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
N = int(input())
S = list(input())
count = 1
word = S[0]
for i in range(1, N):
    if word != S[i]:
        count += 1
        word = S[i]

print(count)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    S = str(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()

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

print(sum)

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

Submission status: Accepted

Solution code:
#
import sys
import math
import numpy as np
import itertools

# ひとつ入力
n = int(input())

# 文字列を一文字ずつのリストに代入 test は['t', 'e', 's', 't']
m = list(input())
answer = n
for i in range(1,n):
    if m[i-1]==m[i]:
        answer -= 1
#print(m)
print(answer)

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:
n = int(input())
strlist = list(input())
count = 0
for i in reversed(range(1,n)):
    if strlist[i] == strlist[i-1]:
        count+=1
        
print(len(strlist)-count)

Submission status: Accepted

Solution code:
N = int(input())
S = list(input())
ans = 0
print(sum(a != b for a, b in zip(S, S[1:])) + 1)

Submission status: Accepted

Solution code:

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

res=[]
tmp=""
for i in range(N):
    if i==0:
        tmp=S[0]
        res.append(S[0])
    else:
        if(tmp==S[i]):
            continue
        else:
            tmp=S[i]
            res.append(S[i])

print(len(res))

Submission status: Accepted

Solution code:
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac
import bisect
import sys
input = sys.stdin.readline

setrecursionlimit(1000000)

dp = defaultdict(lambda x:-1)

def main():
	n = int(input())
	s = input()
	print(len(zip(s)) - 1)

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(l):
	x = l.pop()
	y = l.pop()
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	l.append(min(x,y))
	return gcd(l) if len(l) > 1 else l[0]

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())
S = list(input())
tmpList = [S[0]]
ans = 1
for char in S:
    if tmpList[-1] == char:
        continue
    tmpList.append(char)
    ans+=1
print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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


pattern = "a+|b+|c+|d+|e+|f+|g+|h+|i+|j+|k+|l+|m+|n+|o+|p+|q+|r+|s+|t+|u+|v+|w+|x+|y+|z+"
result = re.finditer(pattern, s)

count=0
for res in result:
  count+=1

print(count)

Submission status: Accepted

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

ret = 0

old = ""
for s in S:
  if s != old:
    ret += 1
    old = s

print(ret)

Submission status: Accepted

Solution code:
from itertools import groupby

input()
print(sum(map(bool, groupby(input()))))

Submission status: Accepted

Solution code:
from sys import stdin
N = int(stdin.readline().rstrip())
S = (stdin.readline().rstrip()) + "@"
cnt = 1
ans = N
for i in range(0,N):
    if S[i] == S[i+1]:
        cnt += 1
    else:
        if cnt != 1:
            ans -= (cnt-1)
        cnt = 1
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
s=list(input())
ans=0;d=""
for i in s:
  if i==d:
    continue
  else:ans+=1;d=i
print(ans)

Submission status: Accepted

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

cnt = 0
cur = S[0]
for i in range(1, N):
    if S[i] == cur:
        continue
    else:
        cnt += 1
        cur = S[i]

cnt += 1

print(cnt)

Submission status: Accepted

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

ans = 1
_x = S[0]
for x in S[1:]:
    if _x == x:
        pass
    else:
        ans += 1
        _x = x

print(ans)

Submission status: Accepted

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

if N==1:
    print(1)
    exit()

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

print(cnt+1)

Submission status: Accepted

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

Submission status: Accepted

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

num = 1

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

print num

Submission status: Accepted

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

ans=1

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

print(ans)

Submission status: Accepted

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

c = 0
p = ''
for s in S:
    if p != s:
        c += 1
    p = s

print(c)

Submission status: Accepted

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

for c in s:
    if c != tmp:
       answer += 1
       tmp = c

print(answer)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    n = int(input())
    s = input()
    bf = ""
    af = ""
    for i in s:
        if bf =="":
            bf = i
            af = i
        else:
            if i != bf:
                af = af +i
                bf = i
    print(len(af))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys


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

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

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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


def solve(N: int, S: str):
    prev =S[0]
    answer = 1
    for ss in S:
        if ss != prev:
            answer += 1
        prev = ss
    print(answer)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
import math
from copy import deepcopy
from collections import deque, defaultdict
from operator import mul
from functools import reduce
sys.setrecursionlimit(20000000)

# input = sys.stdin.readline


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

    pre = ''
    ans = 0

    for s in S:
        if s != pre:
            ans += 1

        pre = s

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

print(c)

Submission status: Accepted

Solution code:
#import heapq
#import itertools
#import math
#import numpy as np
#import sys

N = int(input())
S = list(input())
#A = list(map(int, input().split()))
#S = [input() for _ in range(H)]
#T = [list(map(int,input().split())) for _ in range(N)]
#sys.exit()

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

print(X)

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()
ans = 1
for i in range(1,n):
  if s[i] != s[i-1]:
    ans += 1
    #print(i,s[i])
print(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:
num = int(input())
slime = list(input())
p = num
for i in range(num-1):
  if slime[i] == slime[i+1]:
    p -= 1
print(p)

Submission status: Accepted

Solution code:
import sys
from fractions import gcd
from functools import reduce
from itertools import combinations
from random import random

import numpy as np

sys.setrecursionlimit(200000)


class Solver:
    def __init__(self):
        pass

    def input(self):
        """
            faster input function than builtin stdin.
        """
        return sys.stdin.readline()[:-1]

    def ii(self, t: type = int):
        """
            input single value.
        """
        return t(self.input())

    def il(self, t: type = int):
        """
            input single line.
        """
        return list(map(t, self.input().split()))

    def imi(self, N: int, t: type = int):
        return [self.ii(t) for _ in range(N)]

    def iml(self, N: int, t: type = int):
        return [self.il(t) for _ in range(N)]

    def solve(self):
        N = self.ii()
        S = self.ii(t=str)
        current = S[0]
        ans = S[0]
        for s in S[1:]:
            if current == s:
                continue
            ans += s
            current = s
        return len(ans)


if __name__ == "__main__":
    solver = Solver()
    print(solver.solve())

Submission status: Accepted

Solution code:
N = int(input())
S = list(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=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())
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:
# coding: utf-8
# Your code here!

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


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

Submission status: Accepted

Solution code:
_ = input()
s = input()
res = [s[0]]
index = 0
for slime in s[1:]:
	if res[index] != slime :
		res.append(slime)
		index += 1
print(len(res))

Submission status: Accepted

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

Submission status: Accepted

Solution code:

n = int(input())
s = input()
ans = 1
ima = s[0]
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()
if N==1:
  print(1)
  exit()
f=1
for i in range(1,N):
  if S[i]==S[i-1]:
    pass
  else:
    f+=1
print(f)

Submission status: Accepted

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

count = 0

prevColor = S[0]
count += 1

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

print(count)