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

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

Submission status: Accepted

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

current = ""
result = []

for slime in S:
    if slime == current:
        continue
    else:
        current = slime
        result.append(slime)
print(len(result))

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())
color = str(input())
ans = 1
for i in range(n-1):
    if(color[i] != color[i+1]):
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
from itertools import groupby
N = int(input())
S = list(input())
gr = groupby(S)
ans = 0
for key,group in gr:
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
S = list(input())
temp = S[0]
count = 1

for item in S:
    if temp != item:
        count += 1
    temp = item

print(count)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from sys import stdout
printn = lambda x: stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split()) 
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
s = input().strip()
acc = 0
prev = '#'
for i in range(n):
  if s[i] != prev:
    acc += 1
  prev = s[i]
print(acc)

Submission status: Accepted

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

for x in b:
    if x!=s:
        n+=1
    s=x
print(n)

Submission status: Accepted

Solution code:
n = int(input())
#a,b = map(int,input().split())
#li = list(map(int,input().split()))
s = list(input())
num = 0
for i in range(n-1):
    if s[i] != s[i+1]:
        num += 1
print(num+1)

Submission status: Accepted

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

Submission status: Accepted

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

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

    if cur_c != before_c:
        count += 1
    before_c = cur_c

print(count)

Submission status: Accepted

Solution code:
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    S = str(input().strip())

    cnt = 0
    color = '_'
    for s in S:
        if s == color:
            continue
        cnt += 1
        color = s

    return cnt

if __name__ == '__main__':
    print(main())

Submission status: Accepted

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

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

print(t)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

#+++++
		
def main():
	a = int(input())
	s = input()
	if a == 1:
		return 1
	
	cc=s[0]
	count=1
	for c in s[1:]:
		#print(c)
		if c != cc:
			count+=1
			cc=c
	
	return count
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    N = int(input())
    S = input()

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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


def solve(N, S):
    ans = 0
    last = ''
    for c in S:
        if c != last:
            last = c
            ans += 1
    return ans


if __name__ == '__main__':
    N = int(input())
    S = input()

    ans = solve(N, S)

    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(c)

Submission status: Accepted

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

ans = 1



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

Submission status: Accepted

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

from itertools import groupby
ans = len([x[0] for x in groupby(S)])
print(ans)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    s = input()
    bef = s[0]
    ans = 1

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

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from itertools import groupby
N = int(input())
S = input()
print(len([[k, len(list(g))] for k, g in groupby(S)]))

Submission status: Accepted

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

#print(result)
print(len(result))

Submission status: Accepted

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

Submission status: Accepted

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

for i,x in enumerate(S):
    if i==0:
        cnt=1
    else:
        if prev!=x:
            cnt+=1
    prev=x

print cnt

Submission status: Accepted

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

N = int(input())
slime = list(input())
slime.pop(-1)
now = slime[0]
nagasa = len(slime)

for i in range(1, nagasa):
    if now == slime[i]:
        nagasa -= 1
    else:
        now = slime[i]
print(nagasa)

Submission status: Accepted

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

fusioned_slimes = ""
prev_slime = ""
for slime in slimes:
	if slime != prev_slime:
		fusioned_slimes += slime
		prev_slime = slime

print(len(fusioned_slimes))

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(cnt+1)

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

Submission status: Accepted

Solution code:
from sys import stdin

n = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()

ne = s[0]

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

print(len(ne))

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:
def f(s):
    c = 0
    for i in range(len(s)):
        if i == 0:
            c = 1
        elif s[i - 1] == s[i]:
            pass
        else:
            c += 1
    return c

assert f("aabbbbaaca") == 5
assert f("aaaaa") == 1
assert f("xxzaffeeeeddfkkkkllq") == 10

_n = input()
s = input()
ans = f(s)
print(ans)

Submission status: Accepted

Solution code:
def resolve():
    _ = int(input())
    S = input()
    prev = S[0]
    cnt = 1
    for c in S[1:]:
        if prev != c:
            cnt += 1
            prev = c 
    print(cnt) 
resolve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

count = 0

pre = ""
for s in S:
    if pre == "":
        pre = s
        count += 1
        continue

    if pre != s:
        pre = s
        count += 1

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
list1 = list(input())
list2 = []
cout = 1
i = 0
while i < n-1:
    if list1[i] != list1[i+1]:
        cout += 1
        i += 1
    else:

        i += 1

print(cout)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

res = []
for x in s:
    if len(res) == 0:
        res.append(x)
    if res[-1] != x:
        res.append(x)

print(len(res))

Submission status: Accepted

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

cnt = 0
pre_slime = S[0]
for s in S[1:]:
    if pre_slime == s:
        continue
    pre_slime = s
    cnt += 1

print(cnt+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# submission # - User: herp_sy
# https://atcoder.jp/contests/
#
# lang: Python3 (3.4.3)

import math
import statistics
import numpy as np
import queue

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

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

Submission status: Accepted

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

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

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

if S[-1] != pre:
    ans += 2
else:
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
s=list(input())
cnt=0
for c,d in zip(s[0:],s[1:]):
  #print(c,d)
  if c!=d:
    cnt+=1
  
print(cnt+1)

Submission status: Accepted

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

Submission status: Accepted

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

cnt = 0
w = ''
for i in range(N):
    if S[i] == w:
        continue
    w = S[i]
    cnt += 1
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    _ = input()
    S = input()
    old = ""
    ans = 0
    for color in S:
        if color != old:
            ans += 1
        old = color
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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()
a = 1
for i in range(1,N):
    if s[i] != s[i-1]:
        a += 1
print(a)

Submission status: Accepted

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

ans = 0
x = 'X'
for s in S:
  if x != s:
    ans += 1
  x = s
  
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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


def solve():
	if not slimes:
		print(0)
		return

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

solve()

Submission status: Accepted

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]
N = int(input())
S = input()
if N==1:
    print(1)
    exit()
pre = S[0]
flag = False
cnt = 1
for i in range(1,N):
    k = S[i]
    if pre==k:
        if flag:
            pass
        else:
            flag = True
    else:
        cnt += 1
        flag = False
    pre = k
print(cnt)

Submission status: Accepted

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

count = 1

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

print(count)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 20 20:47:47 2019

@author: Owner
"""

import numpy as np
import sys
import collections
import scipy.misc
import math
from operator import itemgetter
import itertools
import copy
import bisect
import heapq

#素因数を並べる
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(int(n))
  return table   
# 桁数を吐く
def digit(i):
    if i > 0:
        return digit(i//10) + [i%10]
    else:
        return []
    
def getNearestValueIndex(list, num):
    """
    概要: リストからある値に最も近い値のインデックスを取得する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx

def find_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        """
        x が属するグループを探索
        """
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        """
        x と y のグループを結合
        """
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        """
        x と y が同じグループか否か
        """
        return self.find(x) == self.find(y)

    def get_size(self, x):
        """
        x が属するグループの要素数
        """
        x = self.find(x)
        return self.size[x]
    



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

    
def main(): 
    res = N
    now = S[0]
    for n in range(1,len(S)):
        if now == S[n]:
            res -= 1
        now = S[n]
    print(res)
                
                
                
            
            
                

    
if __name__ == '__main__':
    main()



"""
N, X = map(int, input().split())

x = list(map(int, input().split()))

P = [0]*N
Y = [0]*N
for n in range(N):
    P[n], Y[n] = map(int, input().split())


all(nstr.count(c) for c in '753')

# 複数配列を並び替え
ABT = zip(A, B, totAB)
# itemgetterには何番目の配列をキーにしたいか渡します
A, B, totAB = zip(*ABT)

# 2進数のbit判定
(x >> i) & 1

# dp最小化問題
dp = [np.inf]*N
for n in range(N):
    if n == 0:
        dp[n] = 0
    else:
        for k in range(1,K+1):
            if n-k >= 0:
                dp[n] = min(dp[n], dp[n-k] + abs(h[n]-h[n-k]))
            else:
                break
# 累積和
add = 1 # 問題によって決まる
res = 0
sums = [0]*(len(nums)+1)
for i in range(len(nums)):
    sums[i+1] = sums[i] + nums[i]
for i in range(0, len(nums), 2):
    left = i
    right = min(i+add, len(nums))
    tmp = sums[right] - sums[left]
    res = max(tmp, res)

#２分探索
li, ri = bisect.bisect_left(p_ac, l[i]-1), bisect.bisect_right(p_ac, r[i]-1)    

#ソート関数
org_list = [3, 1, 4, 5, 2]
new_list = sorted(org_list)
print(org_list)
print(new_list)
# [3, 1, 4, 5, 2]
# [1, 2, 3, 4, 5]

#Distance Transformation
    for h in range(0,H):
        for w in range(0,W):
            if h == 0 and w == 0:
                pass
            elif h == 0:
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h-1][W-w]+1)
            elif w == 0:   
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h][W-w-1]+1)
            else:
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h][W-w-1]+1, D[H-h-1][W-w]+1, D[H-h][W-w]+2)
            d_max = max(D[H-h-1][W-w-1], d_max)

"""

Submission status: Accepted

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

slimes = []
cur = 0
peek = 0
for i in range(n):
    if s[cur] == s[i]:
        peek = i
    else:
        slimes.append(s[cur])
        cur = i
        peek = i

slimes.append(s[cur])
print(len(slimes))

Submission status: Accepted

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

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

print(N-num)

Submission status: Accepted

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

ans = 1
prev = s[0]

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

print(ans)

Submission status: Accepted

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

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

print(cnt+1)

Submission status: Accepted

Solution code:
from itertools import groupby

N = int(input())
s = list(input())

ans = len([x[0] for x in groupby(s)])
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline


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

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

    print(len(result))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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


if len(S)==1:
    print(1)
else:
    value=1
    tmp = S[0]
    for i in S[1:]:
        if i==tmp:
            continue
        else:
            tmp=i
            value+=1
    print(value)

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

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
n=int(input())
s=input()
from itertools import groupby
print(sum(1 for k,g in groupby(s)))

Submission status: Accepted

Solution code:
N = int(input())
S = input()
# n, *a = map(int, open(0))
# M, D = map(int, input().split())
# A = list(map(int, input().split()))
# S = input()
cnt = 0
new = "-"
for c in S:
    if c == new[-1]:
        continue
    new += c
print(len(new) - 1)

Submission status: Accepted

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

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

Submission status: Accepted

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

c=0
ans=n
for i in xrange(len(s)-1):
    if s[i]==s[i+1]:
        c+=1
    else:
        ans-=c
        c=0

if c!=0:
    ans-=c

print ans

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
hoge=input()
ans=n
bef=hoge[0]
for i in range(1,n):
  now=hoge[i]
  if(now==bef):
    ans-=1
  bef=now
  
print(ans)

Submission status: Accepted

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

S_len = len(S)

d_count = 0
for i in range(S_len-1):
    if S[i] == S[i+1]:
        d_count += 1

print(S_len - d_count)

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(str,input()))

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

print(ans)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    n = int(input())
    s = input()

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

    print(answer)

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:
import sys

input = sys.stdin.readline

N = int(input())
S = input().strip()

ans = 0
pre = ''
for si in S:
	if si != pre:
		ans += 1
		pre = si

print(ans)

Submission status: Accepted

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

prev = ''
num = 0
for c in s:
  if prev != c:
    num += 1

  prev = c

print(num)

Submission status: Accepted

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

cnt = 1
pre = S[0]
S2 = S[1:]
for s in S2:
    if s==pre:
        pass
    else:
        cnt += 1
        pre = s

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N = int(input())
        S = input().rstrip()

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

        print(ans + 1)


# Run main
if __name__ == '__main__':
    AtCoder().main()

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    S = list(inputs[0])

    types = 0
    prev_color = None

    for c in S:
        if prev_color != None and prev_color != c:
            types += 1
        prev_color = c
    types += 1
    return types


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    input()
    ret = solve(inputs(1))
    print(ret)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
s = list(input())
ans = len(s)
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=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())
ans=n
s0=input()
for i in range(n-1):
    if s0[i]==s0[i+1]:
        ans-=1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

res = 1
last = arr[0]
for i in range(1,n):
	if(arr[i] != last):
		res += 1
		last = arr[i]

print(res)

Submission status: Accepted

Solution code:
N=int(input())
S=list(input())
ans=0
old='xxx'
for s in S:
    if s!=old:
        ans+=1
    old=s
print(ans)

Submission status: Accepted

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

ret = 0
prev = "#"
i = 0

while i < len(s):
	if s[i] != prev:
		ret += 1
	prev = s[i]
	i+=1

print(ret)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())
S = list(input())
cnt = 1
b = S[0]

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

Submission status: Accepted

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

ans = 0
i = 0
while True:
    c = s[i]
    ans += 1
    while i < n and c == s[i]:
        i += 1
    if i == n:
        break
print(ans)

Submission status: Accepted

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

slimes = 0

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

print(slimes + 1)

Submission status: Accepted

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

from itertools import groupby
ans = len(list(groupby(s)))

print(ans)

Submission status: Accepted

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

count = 1
s_pre = S[0]
for s in S[1:]:
    if s_pre != s:
        count +=1
    s_pre = s

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

prev = 'A'
cnt=0
for c in s:
  if c != prev:
    prev = c
    cnt += 1
    
print(cnt)

Submission status: Accepted

Solution code:
from itertools import groupby


n = int(input())
s = input()
s_group = list(groupby(s))
print(len(s_group))

Submission status: Accepted

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

print(len(t)+1)

Submission status: Accepted

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

pre = S[0]
ans = 1
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()

pre = S[0]
c = 1
for i in range(1,N):
    if pre == S[i]:
        continue
    else:
        c+=1
    pre = S[i]
print(c)

Submission status: Accepted

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

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

print(len(ans))

Submission status: Accepted

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import groupby
N = int(input())
S = input()
runlength = [len(list(v)) for k,v in groupby(S)]
print(len(runlength))

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:
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
n = int(input())
d = input()

prev = ""
ret = 0

for i in range(len(d)):
    if prev != d[i]:
        prev = d[i]
        ret += 1

print(ret)