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

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

print(c)

Submission status: Accepted

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

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

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

count = 1
result = []
for i in range(N) :
  if i == 0 :
    before = S[i]
    continue
  if before == S[i] :
    count += 1
  else :
    result.append(count)
    count = 1
    before = S[i]

result.append(count)
print(len(result))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
#a,b=map(int,input().split())
#n,k=map(int,input().split())
#d=list(map(int,input().split()))
s=list(input())
s.append("?")
ans=0
for i in range(n):
    if s[i]!=s[i+1]:
        ans+=1
print(ans)

Submission status: Accepted

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

len = 0
for i in range(N):
    if i < N:
        if S[i:i+1] != S[i+1:i+2]:
            len = len + 1
print(len)

Submission status: Accepted

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

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

print(len(stack))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re
count = input()
string = input()
result = 1
for num_word in range(0, len(string) - 1):
    if string[num_word] != string[num_word + 1]:
        result += 1
print(result)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

a = 1

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

Submission status: Accepted

Solution code:



if __name__ == "__main__":
  n = int(input())
  vals = list(input())
  # print(vals)
  res=1
  prev = vals[0]
  for idx, val in enumerate(vals[1:]):
    if val == prev:
      continue
    else:
      prev = val
      res += 1

  print(res)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
s=input()
s+='Q'
cnt=0
for i in range(0,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 = 0
current_s = "0"
for s in S:
    if s != current_s:
        current_s = s
        ans += 1
        
print(ans)

Submission status: Accepted

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

print(sum(1 for a, b in zip('_' + S, S) if a != b))

Submission status: Accepted

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

    # aaa|bbb|ccが3であることを数えるには2つ方法がある。
    # (1)連続する文字を一つのグループとみなして、その境界を数える。
    # (2)隣り合ったものを本当に削除する→そういう関数があれば使う
    # 境界が二つあればグループは3つ。

    ans = 0

    # 境界は最後の要素の一つ前までチェックすればよい。
    for i in range(n-1):
        if s[i] != s[i + 1]:
            ans += 1
    print(ans + 1)
    
if __name__ == '__main__':
    answer_143c()

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N, S = open(0).read().split()
    print(sum(1 for x, y in zip(S[:], S[1:]) if x != y) + 1)
    return


main()

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n = I()
    s = S()
    r = 0
    t = '-'
    for c in s:
        if c != t:
            r += 1
            t = c

    return r


print(main())

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

class Solution(object):
    def __init__(self):
        self.n = int(sys.stdin.readline())
        self.colors = sys.stdin.readline()

    def get_combined_slimes(self):
        count = 1
        curr_color = self.colors[0]
        for i in range(1, len(self.colors)-1):
            if curr_color != self.colors[i]:
                #print("curr color ", curr_color)
                #print("new color ", self.colors[i])
                curr_color = self.colors[i]
                count += 1
        return count

if __name__ == "__main__":
    s = Solution()
    print(s.get_combined_slimes())

Submission status: Accepted

Solution code:
n = int(input())
s = [str(i) for i in input()]
tmp = "0"
st = []

for i in range(n):
    if s[i] == tmp:
        pass
    else:
        st.append(s[i])
        tmp = s[i]

print(len(st))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

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

slime = 0
current = ''

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

print(slime)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    input()
    s=input()
    from itertools import groupby
    print(len(list(groupby(s))))
resolve()

Submission status: Accepted

Solution code:
from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *
from sys import stdin
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))

def pow(a,b):
	if(b==0):
		return 1
	else:
		val=pow(a,int(b/2))
		if(b%2==0):
			return val*val
		else:
			if(b>0):
				return a*val*val
			else:
				return (val*val)//a

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

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:
a = int(input())
s = list(input())
i = 0
while(i<len(s)-1):
  if s[i] == s[i+1]:
    s.pop(i)
  else:
    i+=1
print(len(s))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
l=list(input())
now=l[0]
count=0
for i in range(1,n):
  if now!=l[i]:
    count+=1
    now=l[i]
  else:
    pass
print(count+1)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
n = int(input())
s = input()

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

Submission status: Accepted

Solution code:
# ABC143C - Slimes
from itertools import groupby


def main():
    N = int(input())
    S = input().rstrip()
    ans = len(list(groupby(S)))
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

prev = None
count = 0

for i in S:
  if prev != i:
    prev = i
    count += 1
    
print(count)

Submission status: Accepted

Solution code:
n = int(input())
s = input()
def get_sequence(arr):
  if len(arr) == 0:
    return [], []
  elements = []
  nums = []
  n = 1
  prev = arr[0]
  for c in arr[1:]:
    if c == prev:
      n += 1
    else:
      elements.append(prev)
      nums.append(n)
      prev = c
      n = 1
  elements.append(prev)
  nums.append(n)
  return elements, nums
print(len(get_sequence(s)[0]))

Submission status: Accepted

Solution code:

x = int(input())
s = input()
k = s[0]
ans = 1
for i in range(x):
    if k != s[i]:
        ans = ans + 1
        k = s[i]
print(ans)

Submission status: Accepted

Solution code:
def c_slimes():
    from itertools import groupby
    N = int(input())
    S = input()
    return len([k for k, v in groupby(S)])

print(c_slimes())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = int(input())
b = input()
s = 1
for i,j in zip(b,b[1:]):
    if i != j :s+=1
print(s)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict, deque
from heapq import *
sys.setrecursionlimit(200000)
input = sys.stdin.readline

# N, M, = map(int, input().split())
N = int(input())
# L = [int(v) for v in input().split()]
# L = [[int(v) for v in input().split()] for _ in range(N)]
# L = [int(input()) for _ in range(N)]
# L = [list(input().strip())  for _ in range(N)]
S = input().strip()

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

print(len(ans))

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

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

print(N - 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 =1
now_number =0

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

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

Submission status: Accepted

Solution code:
N = int(input())
S = input()
ans, pre = 0, "*"
for s in S:
    if s != pre:
        ans += 1
    pre = s

print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
input = stdin.readline
lmi = lambda: list(map(int, input().split()))
mi = lambda: map(int, input().split())

n = int(input())
s = input().strip('\n')
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=list(input())

count=0
while True:
    try:
        if S[count]==S[count+1]:S.pop(count)
        else:count+=1
    except:break
print(len(S))

Submission status: Accepted

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

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

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

    prev = S[i]

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

result = []

for i in range(int(n)):
    if s[i:i + 1] != s[i + 1:i + 2]:
        result.append(s[i:i + 1])

print(len(result))

Submission status: Accepted

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

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

Submission status: Accepted

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

groups = 0
s_prev = -1
for s in S:
    if s != s_prev:
        groups += 1
    s_prev = s

print(groups)

Submission status: Accepted

Solution code:
_,s=open(0)
print(sum(s!=t for s,t in zip(s,s[1:])))

Submission status: Accepted

Solution code:
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()
answer = [S[0]]
for i in range(1, N):
    if S[i] != S[i-1]:
        answer.append(S[i])
print(len(answer))

Submission status: Accepted

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

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

ans += 1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
pre = None
for c in input():
    if c != pre:
        ans += 1
        pre = c
print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  s=list(S())

  _a=''
  ans=[]

  while len(s)>0:
    if _a==s[-1]:
      s.pop()
    else:
      _a=s.pop()
      ans.append(_a)

  return len(ans)

# main()
print(main())

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
input()
S = [i for i in input()]
point = 0
del_list = list()
for i in range(point,len(S)-1):
  if S[i] == S[i+1]:
    del_list.append(i)
for i,j in enumerate(del_list,0):
  del S[j-i]
      
print(len(S))

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

count=0
while len(S)>count:
    try:
        if S[count]==S[count+1]:S.pop(count)
        else:count+=1
    except:break
print(len(S))

Submission status: Accepted

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

Submission status: Accepted

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

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=''
n=0
for i in s:
    if ans != i:
        n +=1    
    ans=i
print(n)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

out = 0
now = ""

for i in range(len(L)):
  if L[i] != now:
    out += 1
    now = L[i]
print(out)

Submission status: Accepted

Solution code:
# coding: utf-8


n = int(input().rstrip())
s = list(input())
count = 0
 
 
for i in range(n):
    
    try:
        if s[i] == s[i+1]:
            count += 1
    except IndexError:
        break
        
        
print(len(s) - count)

Submission status: Accepted

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

Submission status: Accepted

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

x = S[0]
ans = 1
for s in S[1:]:
    if s != x:
        ans += 1
        x = s

print(ans)

Submission status: Accepted

Solution code:
N=int(input())
S=str(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 = list(input())
char = ''
n = 0
for i in S:
    if not char == i:
        n += 1
    char = i
print(n)

Submission status: Accepted

Solution code:
N = int(input())
S = input()
temp = "X"
ans = 0
for s in S:
    if s != temp:
        ans += 1
        temp = s
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

if ans == '' or (ans[-1] != S[-1]):
    ans += S[-1]

print(len(ans))

Submission status: Accepted

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

ans=N

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

print(ans)

Submission status: Accepted

Solution code:
import copy

def j(n):
    if n:print("yes")
    else:print("no")
    exit(0)
rem = 10 ** 9 + 7

"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def ipmultiplerow(n):
    a = []
    for i in range(n):
        a.append(ip())
    return a
def printrow(a):
    for i in a:
        print(i)
ct = 1
n = ip()
a = input()
current = a[0]
for i in range(1,n):
    if current != a[i]:
        current = a[i]
        ct+=1
print(ct)

Submission status: Accepted

Solution code:
n = int(input())

s = input()

res = 1

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

print(res)

Submission status: Accepted

Solution code:
n = input()
s = list(input())
ss = ''
sss = []

for i in s:
    if i != ss:
        sss.append(i)
    ss = i

print(len(sss))

Submission status: Accepted

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

lis = list(str(S))

count = N
c = 0

for i in lis:
    c += 1
    if len(lis) == c:
            print(count)
    elif lis[c - 1] == lis[c]:
        count -= 1

Submission status: Accepted

Solution code:
import sys

n = int(input())
s = input()
i = 0
ck = ''
result = ''
for i in range(len(s) - 1):
	if s[i] == s[i + 1]:
		if s[i] != ck:
			ck = s[i]
			result += ck
	elif s[i] != ck:
		ck = s[i]
		result += ck

if s[-1:] != ck:
	result += s[-1:]

print(len(result))

Submission status: Accepted

Solution code:
from itertools import groupby

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

G = [len(tuple(v)) for k, v in groupby(S)]
print(len(G))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(N)

Submission status: Accepted

Solution code:
# C - Slimes
n = (int)(input())
s = input()

sum = 0

pre = ''
for i in s:
    if i == pre:
        pre = i
        continue
    else:
        pre = i
        sum += 1

print(sum)

Submission status: Accepted

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

import re


def nchars(s, n):
    assert n > 0
    reg = re.compile("(.)\\1{%d,}" % (n - 1))
    while True:
        m = reg.search(s)
        if not m:
            break
        yield m.group(0)
        s = s[m.end():]
        
ans = list(nchars(S,1))
ans = len(ans)
print(ans)

Submission status: Accepted

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

m = 0

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

Submission status: Accepted

Solution code:
import re
n = int(input())
s = input()
ans = s
for i in range(26):
  ans = re.sub("([a-z])\\1","\\1",ans)
print(len(ans))

Submission status: Accepted

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

cnt = 0

now = ''
for i in s:
  if now != i:
    cnt += 1
  now = i

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
d=str(input())
total=""
a=0
while a!=n:
    total+=d[a]
    a+=1
    if a==n:
        break
    while d[a]==d[a-1]:
        a+=1
        if a==n:
            break
    
print(len(total))

Submission status: Accepted

Solution code:
N = int(input())
slime = str(input())
ans_list = []
previous_slime = ""
#print(slime)
for i in range(N):
  #print(slime[i])
  if slime[i] != previous_slime:
    ans_list.append(slime[i])
    previous_slime = slime[i]

print(len(ans_list))

Submission status: Accepted

Solution code:
N = int(input())
S = input()
buffer = S[0]
output = buffer
for s in S:
    if s == buffer:
        pass
    else:
        buffer = s
        output += s
print(len(output))

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 = input()
S = input()
count = 0
result = ''

for s in S:
    # if result:
    count += 1

    if result == '':
        result += s
    else:
        if result[-1] != s:
            result += s
    if count >= int(N):
        # print('break')
        break


print(len(result))

Submission status: Accepted

Solution code:
n = int(input())
s = input()
idx = 0
idx = 1
ans = 1
if n == 1:
    print(1)
else:
    tmp = s[0]
    while(idx<n):
        if s[idx]==tmp:
            idx += 1
        else:
            tmp = s[idx]
            idx += 1
            ans +=1
    print(ans)

Submission status: Accepted

Solution code:
n = int(input())
s =  [str(m) for m in list(str(input()))]
nd = list()
for i in range(n-1):
        if s[i] != s[i+1]:
            nd.append(s[i])

print(len(nd)+1)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
S = input()
l = 0
S = list(S)
while len(S) != l+1:
    if S[l] == S[l+1]:
        del S[l]
    else:
        l += 1
print(len(S))

Submission status: Accepted

Solution code:
n = int(input())
data = list(input().rstrip())
ans = [data[0]]
cnt = 0
i = 0

for _ in range(n):
  if ans[-1] != data[i]:
    ans.append(data[i])
  i += 1
    
print(len(ans))

Submission status: Accepted

Solution code:
n=int(input())
s=input()
ss=set(s)
l=s[0]
count=1
for j in range(n):
    if l!=s[j]:
        count+=1
        l=s[j]
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

n=int(N)
c = reduce(lambda x,y: x+y if x[-1] != y else x, S)

print len(c)

Submission status: Accepted

Solution code:
N, S = open(0).read().split()
#print(N, S)
S = list(S)
cnt=0
for i in range(len(S)):
    for j in range(i+1, len(S)):
        if S[i] == S[i+1]:
            S.pop(i+1)
        else:
            cnt += 1
            #print(cnt,S)
            break
print(len(S))

Submission status: Accepted

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

x = re.sub("(.)\\1{1,}", "-", S)
print(len(x))

Submission status: Accepted

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

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

print(num)

Submission status: Accepted

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

print(result)

Submission status: Accepted

Solution code:
# C: Slimes

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

s_shrinked = str()

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

Submission status: Accepted

Solution code:
import itertools

N = int(input())
L = str(input())

l = [k for k, v in itertools.groupby(L)]

print(len(l))

Submission status: Accepted

Solution code:
N = int ( input() )
slimes = str( input() )
list_slimes = list( slimes )
while(True):
  counter = 0
  i = 0
  while(i<len(list_slimes)-1):
    if list_slimes[i] == list_slimes[i+1]:
      del list_slimes[i]
      counter += 1
    i += 1
  if counter == 0:
    break

print( len (list_slimes) )

Submission status: Accepted

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

S=S +"1"
state=0
bonus_sum=0
gokei=0
bonus=0

for i in range(N):
    #print("gokei",gokei)
    #print("bonus", bonus)
    #print("bonus_sum", bonus_sum)
    #print(S[i],S[i+1])
    
    if S[i] != S[i +1 ]:
        gokei=gokei+1
        bonus_sum=bonus_sum +bonus
        bonus=0
    else:
        gokei=gokei +1
        bonus = bonus +1

        
print(gokei - bonus_sum)

Submission status: Accepted

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

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

Submission status: Accepted

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

previous = S[0]
ans = 1

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

print(ans)

Submission status: Accepted

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

con = 0

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

if S[0] == S[-1]:
	print(N - con + 1)
else:print(N - con)

Submission status: Accepted

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

for s in set(list(S)):
    S = re.sub(r"{}+".format(s), s, S)

print(len(S))

Submission status: Accepted

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

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

print(n-sum)

Submission status: Accepted

Solution code:
slime_sum = input()
slime_color = input()

slime_result_sum_list = []
tmp_color = ""

for color in slime_color:
    if not slime_result_sum_list:
        slime_result_sum_list.append(color)
        tmp_color = color
        continue
    
    if tmp_color != color:
        slime_result_sum_list.append(color)
        tmp_color = color

print(len(slime_result_sum_list))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

S = input().strip()

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

print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
n = int(raw_input())
s = raw_input()


clist = ['aa','bb','cc','dd','ee','ff','gg','hh','ii','jj','kk','ll','mm','nn','oo','pp','qq','rr','ss','tt','uu','ww','vv','xx','yy','zz']

for word in clist:
    while True:
        if s.count(word) > 0:
            s = s.replace(word,word[0])
        else:
            break

print len(s)