n = int(input()) s = input().strip() if n == 0: print(0) exit() # Count the number of color changes when moving from right to left count = 1 prev = s[-1] for i in range(n-2, -1, -1): if s[i] != prev: count += 1 prev = s[i] # Count the number of times a color is the same as two positions to the right d = 0 for i in range(n-3, -1, -1): if s[i] == s[i+2]: d += 1 print(count - d)