n = int(eval(input()))

s = eval(input())

f = 1

while f == 1:

  ns = ""

  pre_c = s[0]

  f = 0

  for c in s[1:]:

    if c != pre_c:

      ns += pre_c

    else:

      f = 1

    pre_c = c    

  ns += s[-1]

  s = ns

print((len(s)))



  
n = int(eval(input()))

s = eval(input())

ns = ""

pre_c = s[0]

for c in s[1:]:

  if c != pre_c:

    ns += pre_c

  pre_c = c    

ns += s[-1]

s = ns

print((len(s)))



  
n = int(eval(input()))
s = eval(input())
f = 1
while f == 1:
    ns = ""
    pre_c = s[0]
    f = 0
    for c in s[1:]:
        if c != pre_c:
            ns += pre_c
        else:
            f = 1
        pre_c = c
    ns += s[-1]
    s = ns
print((len(s)))

n = int(eval(input()))
s = eval(input())
ns = ""
pre_c = s[0]
for c in s[1:]:
    if c != pre_c:
        ns += pre_c
    pre_c = c
ns += s[-1]
s = ns
print((len(s)))

-f = 1 -while f == 1: -    ns = "" -    pre_c = s[0] -    f = 0 -    for c in s[1:]: -        if c != pre_c: -            ns += pre_c -        else: -            f = 1 -        pre_c = c -    ns += s[-1] -    s = ns +ns = "" +pre_c = s[0] +for c in s[1:]: +    if c != pre_c: +        ns += pre_c +    pre_c = c +ns += s[-1] +s = ns