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

Solution (Python):

import sys


def readline():
    return sys.stdin.readline().rstrip()


def read(f=int):
    return f(readline())


def reads(f=int):
    return list(map(f, readline().split()))


def read_n(n: int, f=int):
    return [read(f) for _ in range(n)]


def reads_n(n: int, f=int):
    return [reads(f) for _ in range(n)]

N = read()
S = read(str)

slime = 0

prev = None
for s in S:
        if prev == s:
                continue
        slime += 1
        prev = s

print(slime)

Solution (Python):
N = int(input())
S = list(input())
char = S[0]
ans = 1
for i in range(1,N):
  if char==S[i]:
    continue
  else:
    char=S[i]
    ans+=1

print(ans)

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

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

Solution (Python):
n=int(input())
s=input()+"A"
t=""
for i in range(n):
    if s[i]==s[i+1]:
        continue
    else:
        t +=s[i]

print(len(t))

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

Solution (Python):
N = int(input())

S = input()


s_list = list(S)

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



print(N-mix)

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

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

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

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

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

print(ans)

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

Solution (Python):
_ = input()
S = input()

lastc = "0"
ans = 0

for c in S:
    if c != lastc:
        lastc = c
        ans += 1

print(ans)

Solution (Python):
n = input()
t = n
s = raw_input()

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

print t

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

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

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

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

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

print(c)

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

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

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

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

print(cnt)

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

rtn = 0
ma = "-"
for si in s:
    if (ma != si):
        rtn += 1
    ma = si

print(rtn)

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

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

Solution (Python):
from itertools import groupby
n=int(input())
s=input()
g=groupby(s)
a=[]
for i,j in g:
  a.append(i)
print(len(a))

Solution (Python):
def f_c():
    n = int(input())
    *s, = input()

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

if __name__ == "__main__":
    f_c()

Solution (Python):
def runlength(S):
    cnt = 1
    d = []
    for i in range(len(S)-1):
        if S[i] == S[i+1]:
            cnt += 1
        else:
            d.append(cnt)
            cnt = 1
    else:
        d.append(cnt)

    return d



def main():
    N = int(input())
    S = input()
    d = runlength(S)
    print(len(d))

  

if __name__ == "__main__":
    main()

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

result = 1

cur = s[0]

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

print(result)

Solution (Python):
import sys


def main():
    n = int(sys.stdin.readline().strip())
    s = sys.stdin.readline().strip()

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


main()

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

pre_s = '@'

ans = 0
for s in S:
    if s != pre_s:
        ans += 1
        pre_s = s
print(ans)

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

Solution (Python):
import re
N = int(input())
S = input()
print(len(re.sub(r"(.)\1+", "!", S)))

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

cur = S[0]
ans = 1
for s in S:
    if cur == s:
        pass
    else:
        ans += 1
        cur = s
        
print(ans)

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

Solution (Python):
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

N = INT()
S = input()

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

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

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

Solution (Python):
N = int(input())
s = list(input())

tmp = ''
ans = ""
for one in s:
    if one == tmp:
        continue
    else:
        tmp = one
        ans += one
print(len(ans))

Solution (Python):
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

N=one_int()
S=one_str()

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

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

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

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

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

Solution (Python):
N,S=open(0);print(sum(s!=t for s,t in zip(S,S[1:])))

Solution (Python):
def read():
    N = int(input().strip())
    S = input().strip()
    return N, S

def rle_encode(S):
    S1 = S + '@'
    rle = list()
    head = 0
    for i in range(0, len(S1)):
        if S1[i] != S1[head]:
            rle.append((S1[head], i-head))
            head = i
    return rle

def solve(N, S):
    return len(rle_encode(S))

if __name__ == '__main__':
    inputs = read()
    print("%d" % solve(*inputs))

Solution (Python):
n = int(input())
s = input()+"?"

ans = 0
now = "?"
for i in range(n+1):
    if i == 0:
        now = s[i]
        continue

    if s[i] == now:
        continue
    else:
        ans += 1
        now = s[i]

print(ans)

Solution (Python):
s = input()
s = input()
res = 1
start = s[0]
for i in s:
  if start != i:
    res+=1
  start = i
print(res)

Solution (Python):






def main():

    n=int(input())
    s=input()
    if n>=2:
        for i in range(1,n):
            if s[i]==s[i-1]:
                n-=1
    print(n)






if __name__ == "__main__":
    main()

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

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

Solution (Python):
N = int(input())
S = input()
pre, ans = S[0], 1

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

print(ans)

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

s = "-1"
ans = 0

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

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

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

    print(len(ans))


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
tmp = ''
ans = 0
for c in input():
    if tmp != c:
        ans += 1
    tmp = c
print(ans)

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

ans = n

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

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

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


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

print(N)

Solution (Python):
N = int(input())
S = list(input())
t = 0
pre = ''
for s in S:
    if pre == s:
        t += 1
    pre = s
print(N-t)

Solution (Python):
import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
mod = 10**9 + 7
inf = float('inf')
N = I()
S = str(input())
ans = int(0)
count = int(0)

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

ans = N -count

print(ans)

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

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

print(n-cnt)

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

sra = []
moji = S[0]
for s in S[1:]:
    if moji != s:
        sra.append(moji)
        moji = s
sra.append(moji)
print(len(sra))

Solution (Python):
import sys
def main():
    N = int(input())
    S = input()
    now = 0
    count = 0
    while True:
        count += 1
        now_color = S[now]
        while now_color == S[now]:
            now += 1
            if now == N:
                print(count)
                exit()

if __name__ == "__main__":
    main()

Solution (Python):


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

Solution (Python):
def main():
    n = int(input())
    s = list(input())
    ans = 0
    for i in range(n-1):
        if s[i]==s[i+1]:
            pass
        else:
            ans +=1
    print(ans+1)
if __name__ == "__main__":
    main()

Solution (Python):

from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


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

    g = 1
    p = s[0]
    for i in s[1:]:
        if i != p:
            g += 1
            p = i

    print(g)




BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")



if __name__ == "__main__":
    main()

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

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

a = 0
p = None
for i in range(len(s)):
    if s[i] != p:
        a += 1
        p = s[i]
print(a)

Solution (Python):
n=int(input())
s=list(input())+[None]
cnt=0
for i in range(n):
    if s[i]==s[i+1]:continue
    cnt+=1
print(cnt)

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

Solution (Python):
n = int(input())
s = list(input().strip())
before = s[0]
ans = 1
for i in range(1, len(s)):
    if s[i] == before:
        continue
    else:
        before = s[i]
        ans += 1
print(ans)

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

ans = 0
color = ""

for s in S:
    if color != s:
        color = s
        ans += 1
print(ans)

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

ans = S[0]
b = S[0]
for si in S[1:]:
    if si == b:
        continue
    else:
        ans += si
    b = si

print(len(ans))

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 7)

def main():
    n = int(input())
    s = input()
    cnt = 1
    for i in range(len(s)-1):
        if s[i] == s[i+1]:
            continue
        else:
            cnt += 1
    print(cnt)


if __name__ == '__main__':
        main()

Solution (Python):
N = int(input())
S = input()
S +="@"
before = S[0]
ans = 0
for i in range(1,N + 1):
    if S[i] != before:
        ans += 1
        before=S[i]
print(ans)

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

count = 1

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

print(count)

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

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

Solution (Python):
n=int(input())
s=input()
c=0 
i=0 
while i<n:
    curr=s[i]
    c+=1 
    while i<n and curr==s[i]:
        i+=1 
print(c)

Solution (Python):






class Solution:
    def main(self):
        N = int(input())
        
        s = input()
        res = 1
        for i in range(N-1):
            if s[i] != s[i+1]:
               res += 1
        print(res)


if __name__ == '__main__':
    Solution().main()

Solution (Python):
def c_slimes():
    from itertools import groupby
    N = int(input())
    S = input()

    ans = [k for k, v in groupby(S)]
    return len(ans)

print(c_slimes())

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

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

slimes = [s[0]]
for c in s[1:]:
  if c != slimes[-1]:
    slimes.append(c)
print(len(slimes))

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

sum = N

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

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

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


if __name__ == '__main__':
    main()

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

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

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

print(ans)

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

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

print(count)

Solution (Python):
from sys import stdin

N = int(stdin.readline().rstrip())
S = stdin.readline().rstrip()
ans = 1

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

print(ans)

Solution (Python):


import sys
import math
import collections



n=int(input())

s = input()



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

print(sum)

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

Solution (Python):

from fractions import gcd

from math import factorial as f

from math import ceil,floor,sqrt

from sys import exit

from copy import deepcopy
import numpy as np

import bisect
import re


ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))



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

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


main()

Solution (Python):
N = int(input())
S = input().strip()
ans = 0
prev = ''
for i in S:
  ans += int(prev != i)
  prev = i
print(ans)

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

Solution (Python):
N = int(input())
S =input()
T = list(S[0])
for i in range(1,len(S)):
    if S[i] != T[-1]:
        T.append(S[i])
print(len(T))

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

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

print(ans)

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

pre = S[0]
num = 1
for s in S:
    if s != pre:
        num += 1
        pre = s
print(num)

Solution (Python):




def main():
  input()
  v = input().strip()
  s = 1

  for a, b in zip(v[:-1], v[1:]):
    if a != b:
      s += 1

  print(s)


if __name__ == '__main__':
  main()

Solution (Python):
import sys; readline = sys.stdin.readline
from collections import deque

N = int(readline())
S = readline().rstrip()

count = 0

now = None

for c in S:
    if c != now:
        count += 1
    now = c

print(count)

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

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

print(ans)

Solution (Python):
def solve():
    data = read()
    result = think(data)
    write(result)


def read():
    n = read_int(1)[0]
    return read_line(n)


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_float(n):
    return list(map(lambda x: float(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(data):
    count = 0
    current_char = ''
    for i in range(len(data)):
        if current_char == data[i]:
            continue
        current_char = data[i]
        count += 1
    return count


def write(result):
    print(result)


if __name__ == '__main__':
    
    
    
    
    solve()

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

Solution (Python):
N = int(input())
S = input()
ans = ""
for i,s in enumerate(S):
    if i == 0:
        ans += s
    elif ans[-1] == s:
        pass
    else:
        ans+=s
print(len(ans))

Solution (Python):
n = int(input())
l = list(input())
t = 0
for i in range(n-1):
    if l[i] != l[i+1]:
        t += 1
print(t+1)

Solution (Python):
def main():
    n = int(input())
    s = input()
    ans = [s[0]]
    for i in range(1,n):
        if s[i] == ans[-1][0]:
            ans[-1] = ans[-1]+s[i]
        else:
            ans.append(s[i])
    print(len(ans))    
    
if __name__ == '__main__':
    main()

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

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

Solution (Python):
N=int(input())
S=list(input())
A=""
ans=[]
for i in range(N):
    if S[i]!=A:
        A=S[i]
        ans.append(A)
print(len(ans))

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

Solution (Python):
input()
S=input()
ans=1
now=S[0]
for s in S[1:]:
  if s!=now:
    ans+=1
    now=s
print(ans)

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

Solution (Python):
def solve():
  N = int(input())
  S = input()
  c = ''
  ans = 0
  for s in S:
    if s == c: continue
    c = s
    ans += 1
  return ans

print(solve())

Solution (Python):
N = int(input())
S = "

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

print(s)

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

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

Solution (Python):
n = int(input())
s = input()
flg = False
cnt = 1
for i in range(1,n):
    if s[i] == s[i-1]:
        continue
    else:
        cnt += 1
print(cnt)

Solution (Python):
N = int(input())
S = input()
head = S[0]
prev = head
ans = 1
for s in S[1:]:
    ans += (prev != s)
    prev = s
print(ans)

Solution (Python):
N=int(input())
D = input()
ans = 1
pre = ""
for d in D:
    if pre and pre!=d:
        ans += 1
    pre = d
print(ans)

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

Solution (Python):
N = int(input())
S = list(input())
now = S[0]
stack = [now]
for i in range(1,N):
    if now == S[i]:
        continue
    else:
        stack.append(S[i])
        now = S[i]
print(len(stack))

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

cnt = 1
pre = s[0]
for cur in s[1:]:
    if cur!=pre:
        cnt += 1
    pre = cur

print(cnt)

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

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

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

Solution (Python):


N = int(input().split()[0])
S = input()
s_list = list(S)
count = 1

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

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

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

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

print(ans)

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

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

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

print(ans)

Solution (Python):
import numpy as np
import math
import sys
sys.setrecursionlimit(10000000)

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

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

if __name__ == '__main__':
    main()

Solution (Python):
n = int(raw_input())
s = raw_input()
ans = 0
prev = -1
for x in s:
	if x != prev:
		ans += 1
	prev = x
print ans

Solution (Python):


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

output = N

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

print(output)

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

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

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

print(ans)

Solution (Python):
import sys
import itertools
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
s = S()

tmp = ""
ans = 0
for i in s:
  if i != tmp:
    ans += 1
    tmp = i
  else:
    continue
else:
  if i != tmp:
    ans += 1
print(ans)

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

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

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

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

print(ans)

Solution (Python):
N = int(input())
S = input()
ans = 1
tmp = [S[0]]
for i in range(1,len(S)):
    if S[i] == tmp[-1]: continue
    else:
        tmp.append(S[i])
        ans += 1
print(ans)

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

ans=1

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

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

a = []
b = 0
for i in range(1,n):
    if s[i] == s[i-1]:
        b += 1
    else:
        a.append(b)
        b = 0
    if i == n-1:
        a.append(b)
        b = 0

c = 0
for i in range(len(a)):
    c += a[i]

print(n-c)

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

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

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

print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(1000000000)
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())

def main():
    N = ii()
    S = input()
    stack = []
    for s in S:
        if not stack or stack[-1] != s:
            stack.append(s)
    print(len(stack))


main()

Solution (Python):
if __name__ == '__main__':
    N = int(input())
    S = input()
    res = 1
    s1 = S[0]
    for s2 in S[1:]:
        if s1 != s2:
            res += 1
            s1 = s2
    print(res)

Solution (Python):
N = int(input())
arr = input()

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

print(result)

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

ans = 0
prev = " "
for c in s:
    if c!=prev:
        ans += 1
    prev = c
if c!=prev: ans+=1
print(ans)

Solution (Python):
N = int(input())
S = input()
prev = ''
cnt = 0
for i in range(N):
    if prev!=S[i]:
        cnt+=1
    prev = S[i]
print(cnt)

Solution (Python):
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))

def main():
    n = ni()
    s = ns()

    res = s[0]
    pre = s[0]
    for i, ss in enumerate(s[1:]):
        if ss == pre:
            pass
        else:
            res += pre
            pre = ss
    if not res:
        print(1)
        return
    print(len(res))
main()

Solution (Python):
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy




def main():
    N = int(input())
    S = input()
    bs = S[0]
    ans = 1
    for s in S[1::]:
        if bs != s:
           bs = s 
           ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
N=int(input())
l=list(input())
res=[l[0],]
for item in l[1:]:
  if res[-1]!=item:
    res.append(item)
print(len(res))

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

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

print(cnt)

Solution (Python):
from fractions import gcd
from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
import sys
from bisect import *
import itertools
import copy
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7


def main():
    n = int(input())
    s = list(input())
    ansl = []
    c = True
    k = ""
    for i in range(n):
        if c:
            k = s[i]
            ansl.append(s[i])
            c = False
        elif not c and k != s[i]:
            k = s[i]
            ansl.append(s[i])
    
    print(len(ansl))




    
            
    

    

    

if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
S = input()
ans = 1

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

Solution (Python):

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

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

Solution (Python):
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

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

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

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

print(ans)

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

Solution (Python):
N = int(input())
S = input()
ans = 1
cont = True
for i in range(1, N):
    if S[i] != S[i-1]:
        ans+=1
print(str(ans))

Solution (Python):
n = int(input())
s = str(input())
counter = 1
checker = s[0]
for i in range(1, n):
    if checker == s[i]:
        continue
    else:
        counter += 1
        checker = s[i]
print(counter)

Solution (Python):
n = int(input())
s = input()
s += "A"
c = 0
for i in range(n):
    if s[i] == s[i+1]:
        None
    else:
        c += 1
print(c)

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

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