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

    ans = 0;
    c = None
    for s in S:
        if s != c:
            c = s
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

t = S[0]
ans = 1
for i in range(1, N):
    if t == S[i]:
        continue
    t = S[i]
    ans += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
s = input()
ans = 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())
d=list(input())
c=d[0]
l=[d[0]]
for x in range(n-1):
    if c!=d[x+1]:
        l.append(d[x+1])
        c=d[x+1]
print(len(l))

Submission status: Accepted

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


def solve(N: int, S: str):
    p = S[0]
    r = [S[0]]
    for i in range(1, N):
        if p != S[i]:
            r.append(S[i])
            p = S[i]
    return r


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
    print(len(solve(N, S)))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans = 1
now = s[0]

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

print(ans)

Submission status: Accepted

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

def run_length(s) -> list:
  res = [[s[0], 1]]
  for i in range(1, len(s)):
    if res[-1][0] == s[i]:
      res[-1][1] += 1
    else:
      res.append([s[i], 1])
  return res

print(len(run_length(S)))

Submission status: Accepted

Solution code:
N = input()
S = raw_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()

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

print(len(s))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
S = input()
seen = S[0]
res = 1
for c in S:
    if c != seen:
        seen = c
        res += 1
print(res)

Submission status: Accepted

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

buf = ""
count = 0
for s in S:
    if s != buf:
        count += 1
    buf = s

print(count)

Submission status: Accepted

Solution code:
def solve(n, s):
    count = 0
    prev = ''
    for l in s:
        if l != prev:
            count += 1
        prev = l
    return count

_n = int(input())
_s = input()
print(solve(_n, _s))

Submission status: Accepted

Solution code:
n = int(input())
S = input()
prev = "@"
res = ""
for i in range(n):
    if S[i] != prev:
        res += S[i]
    prev = S[i]

print(len(res))

Submission status: Accepted

Solution code:
import itertools
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

n = ri()
s = rs()
print(len(list(itertools.groupby(s))))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

    S_list = list(S)

    answer_list = []
    answer_list.append(S_list[0])

    for i in range(len(S_list) - 1):
        if answer_list[-1] != S_list[i+1]:
            answer_list.append(S_list[i+1])


    print(len(answer_list))

if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
n = int(input())

li = list(input())

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

print(n-count)

Submission status: Accepted

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

check = 0

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

Submission status: Accepted

Solution code:
N = input()
S = input()
temp = ""
lst = ""
for cnt in S:
    if temp != cnt:
        temp = cnt
        lst += cnt
print(len(lst))

Submission status: Accepted

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

prev_color = S[0]
res = prev_color
for color in list(S)[1:]:
    if color != prev_color:
        res += color
        prev_color = color

print(len(res))

Submission status: Accepted

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

over = False


def process_slimes(s):
    res = ""
    curr = None
    over = True
    count = 0

    for c in s:
        if not curr:
            curr = c
            count += 1
        elif c != curr:
            res += curr
            curr = c
            count += 1
        else:
            over = False
    res += curr

    return res, count, over


while not over:
    s, count, over = process_slimes(s)

print(count)

Submission status: Accepted

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


def solve(N: int, S: str):
    p = 0
    pre = S[0]
    for i in range(1,N):
        if S[i] == pre:
            p += 1
        pre = S[i]
    print(N - p)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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:
N = int(input())
S = input()

ans = 0
pre_s = '_'
for n in range(0,N):
  _ = S[n]
  if pre_s == _:
    ans += 1
  
  pre_s = _

print(N-ans)

Submission status: Accepted

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

count = 1

for index, s in enumerate(S):
  if index + 1 > len(S) - 1:
    break
  
  if S[index] != S[index+1]:
    count += 1

print(count)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import _collections
import string
from functools import lru_cache
import heapq

class cin():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def mapInt():
        return [int(x) for x in cin.string().split()]
    def stringList(n):
        return [input() for i in range(n)]
    def intListList(n):
        return [cin.mapInt() for i in range(n)]
    def intColsList(n):
        return [int(input()) for i in range(n)]
        
class Math():
    def gcd(a,b):
        if b == 0:
            return a
        return Math.gcd(b,a % b)
    def lcm(a,b):
        return (a * b) // Math.gcd(a,b)
    def roundUp(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Math.roundUp(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

MOD = int(1e09) + 7

def main():
    N = cin.int()
    S = cin.string()
    ans = 1
    for i in range(N - 1):
        if S[i + 1] != S[i]:
            ans+=1
    print(ans)
    return

if __name__ == "__main__":
    main()

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

ans = 0
tmp = ''
for i in S:
    if tmp != i:
        ans += 1
    tmp = i

print(ans)

Submission status: Accepted

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

count = 1
for i in range(d-1):
  if s[i:i+1] != s[i+1:i+2]:
    count+=1
print(count)

Submission status: Accepted

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

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

print(len(s))

Submission status: Accepted

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

for i in range(N-1):
  if d[i]==d[i+1]:
    d[i]='_'
d=[j for j in d if j!='_']
print(len(d))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
S=input()
count=0
a=""

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

Submission status: Accepted

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

    ls = [s[0]]

    index = 1

    while(n -1 >= index):
        if ls[len(ls)-1] != s[index]:
            ls.append(s[index])
        index += 1

    print(len(ls))

if __name__ == '__main__':
    main()

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()
r = []
ans = 1
for i in range(len(s)):
  r.append(s[i])
for i in range(N-1):
  if r[i] != r[i+1]:
    ans += 1
print(ans)

Submission status: Accepted

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

print(color_species)

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

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

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

print(cnt)

Submission status: Accepted

Solution code:
import sys

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

temp = 1
ansarray = []
counter = 0
if N == 1:
    print(1)
    sys.exit()


for i in range(1, N):
    counter += 1
    if S[i] == S[i - 1]:
        temp += 1
    else:
        ansarray.append(temp)
        temp = 1
    if counter == N-1:
        ansarray.append(temp)
        print(len(ansarray))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
S = list(input())
total = n
past = ""
for i in range(n):
  if past == S[i]:
    total -= 1
  past = S[i]
print(total)

Submission status: Accepted

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

string = s[0]

for x in range(1, n):
    if string[-1] == s[x]:
        pass
    else:
        string = string + s[x]

print(len(string))

Submission status: Accepted

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

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

count += 1
print(count)

Submission status: Accepted

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

ans = [S[0]]
pre = S[0]
# i番目の文字がi-1番目と一緒でないなら，追加
for e in S[1:]:
    if e != pre:
        ans.append(e)
        pre = e

#print(ans)
print(len(ans))

Submission status: Accepted

Solution code:
N = int(input())
S =list(map(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:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n = INT()
s = input()
color = 0
ans = 0
for i in range(n):
  if i == 0:
    color = s[0]
    ans = 1
  else:
    if color != s[i]:
      color = s[i]
      ans += 1
print(ans)

Submission status: Accepted

Solution code:
from itertools import groupby
_ = input()
print(len(tuple(groupby(input()))))

Submission status: Accepted

Solution code:
from functools import reduce
_ = input()
S = input()
print(len(reduce(lambda a, b: a if a[-1] == b else a + b , S[1:], S[0])))

Submission status: Accepted

Solution code:
n = int(input())
s = [c for c in input()]

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

print(len(s))

Submission status: Accepted

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

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

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:
# -*- coding: utf-8 -*-
import numpy as np
def fnSolv():
  input()
  s = input()
  sP = "0"
  iRet = 0
  for s0 in s:
    if s0 != sP:
      iRet += 1
    sP = s0
  print(iRet)
if __name__ == '__main__':
  fnSolv()

Submission status: Accepted

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

result=1

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

print(result)

Submission status: Accepted

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

    print(len(slist))

Submission status: Accepted

Solution code:
n = int(input())
d = list(input())
cnt = 1
m = d[0]
for i in d:
    if i == m:
        continue
    else:
        m = i
        cnt +=1
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
s = str(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:
N = int(input())
S = input()
ct = 1
last_c = S[0]
for c in S[1:]:
    if last_c == c:
        continue
    else:
        last_c = c
        ct += 1
print(ct)

Submission status: Accepted

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

s = 1

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

Submission status: Accepted

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

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

print(res)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

tmp = ''
count = 0
for s in S:
    if tmp != s:
        count += 1
    tmp = s

print(count)

Submission status: Accepted

Solution code:
N = int(input())

slimes = list(input())

color = slimes[0]

for col in slimes[1:]:
  if color == col:
    N-=1
  else:
    color = col

print(N)

Submission status: Accepted

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

l=[s[0]]
for i in range(1,n):

    if s[i-1] != s[i]:
        l.append(s[i])

print(len(l))

Submission status: Accepted

Solution code:
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

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

prev = s[0]
ans = 1
for c in s[1:]:
    if c != prev:
        ans += 1
        prev = c

print(ans)

Submission status: Accepted

Solution code:
import sys

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())

sys.setrecursionlimit(10 ** 9)


def main():
    N = INT()
    S = INPUT()

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

    print(cnt)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

N_l = [0] * N
for x in range(N):
    if (x != N-1):
        if (S[x] == S[x+1]):
            N_l[x] = 1

print(N_l.count(0))

Submission status: Accepted

Solution code:
import sys
 
def main():
    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)
 
main()

Submission status: Accepted

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

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

print(len(ans))

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
import sys


def solve(inp):
    N = int(inp.readline().strip())
    S = inp.readline().strip()

    r = 1
    p = S[0]
    for c in list(S):
        if p != c:
            r += 1
        p = c

    return str(r)


def main():
    result = solve(sys.stdin)
    if result:
        print(result)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

print(t)

Submission status: Accepted

Solution code:
def solve():
  n = int(input())
  slimes = input()
  
  if n == 1:
    return 1

  prev = slimes[0]
  r = 1

  for slime in slimes[1:]:
    if prev == slime:
      continue

    r += 1
    prev = slime


  return r

print(solve())

Submission status: Accepted

Solution code:
n = int(input())

s = input()

temp = "0"
counter = 0
for c in s:
  if c != temp:
    counter += 1
    temp = c

print(counter)

Submission status: Accepted

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

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

Submission status: Accepted

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

cnt = 1
cp = s[0]
for i in range(1, n):
  if s[i] != cp:
#    print ('CNT INC at ' + str(s[i]))
    cnt += 1
  cp = s[i]
#  print ('CP=' + str(cp))

print (cnt)

Submission status: Accepted

Solution code:
import itertools

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

    ans = [S[0]]

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

    print(len(ans))
    return 0
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
N = int(input())
S = list(input())
gr = itertools.groupby(S)
ans = len([1 for key, group in gr])
print(ans)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
import numpy as np


# noinspection PyShadowingBuiltinsInspection

def main():
    N = int(input())
    S = input()
    s = S[0]
    for i in range(1, len(S)):
        if not s[-1] == S[i]:
            s += S[i]
    print(len(s))
    return


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

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

n = int(input())
s = input().strip()

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

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 1

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

print(ans)

Submission status: Accepted

Solution code:
a = int(input())
mes = input()
pre = mes[0]
slimes = 0

for i in range(a-1):
	if mes[i] != mes[i+1]:
		slimes += 1

print(slimes+1)

Submission status: Accepted

Solution code:
queue = []

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

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

print(len(queue))

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

S_ans = []
#print(S_ans)

#貪欲法
for i, j in enumerate(S):
  if i == 0:
    S_ans.append(1)
  else:
    if S[i-1] == j:
      S_ans.append(0)
    else:
      S_ans.append(1)
      
print(sum(S_ans))

Submission status: Accepted

Solution code:
def main():

    n = int(input())
    S = input()
    s_length = n
    for i in range(n - 1):
        if S[i] == S[i + 1]:
            s_length -= 1
    print(s_length)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

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

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

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

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

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    S = str(input())
    
    ans = []
    now = "_"
    for i in range(N):
        if now != S[i]:
            now = S[i]
            ans.append(S[i])
            
    print(len(ans))

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
import sys
##  input functions for me
def rsa(sep = ''):
    if sep == '' :
        return input().split() 
    else: return input().split(sep)
def rip(sep = ''):
    if sep == '' :
        return map(int, input().split()) 
    else: return map(int, input().split(sep))
def ria(sep = ''): 
    return list(rip(sep))
def ri(): return int(input())
def rd(): return float(input())
def rs(): return input()
##
def main():
    N = ri()
    S = rs()
    l = []
    l.append(S[0])
    for i in range(1,N):
        if S[i] != l[len(l) - 1]: l.append(S[i])
    print (len(l))


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    S = input()
    result = 0
    slime = ''
    for s in S:
        if slime != s:
            slime = s
            result += 1
        else:
            continue
    print(result)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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()
tmp = "Q"
ans = 0
for Z in S:
	if(Z != tmp):
		ans += 1
		tmp = Z
print(ans)

Submission status: Accepted

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

chuumoku = 1
for i in range(n):
    if chuumoku >= len(s):
        break

    if s[chuumoku] == s[chuumoku - 1]:
        s.pop(chuumoku)
    else:
        chuumoku += 1

print(len(s))

Submission status: Accepted

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

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

Submission status: Accepted

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

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(1,n):
    if s[i]!=s[i-1]:
        ans+=1
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
s=input()
li=""
li+=s[0]
for i in range(n):
    if i>0 and s[i]!=s[i-1]:
        li+=s[i]
print(len(li))

Submission status: Accepted

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

answers = [S[0]]

for i in S:
    if not i == answers[-1]:
        answers.append(i)

ans_str = "".join(answers)

ans = len(ans_str)

print(ans)

Submission status: Accepted

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

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

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

ans_list = [s[0]]
now_color = s[0]
for i in range(1, n):
    if now_color != s[i]:
        ans_list.append(s[i])
        now_color = s[i]
    # print("s[{}]:{} now_color:{} ans_list:{}".format(i, s[i], now_color, ans_list))

print(len(ans_list))

Submission status: Accepted

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

from math import ceil

def main():
    ans = N
    pre = S[0]
    for s in S[1:]:
        if pre == s:
            ans -= 1
        pre = s
    print(ans)
    return

if __name__ == "__main__":
    main()

Submission status: Accepted

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

count = 1
s ='char'

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

print(count)