# Arup Guha
# 3/16/2026
# Solution to 2026 UCF HS Contest Problem G: Displaying Gazebos

# Get input.
n = int(input())
word = input().strip()

# Store longest alternating result.
res = 0

# Loop through.
i = 0
while i < n:

    # Go through this streak.
    j = i+1
    while j<n and word[i] == word[j]:
        j += 1

    # New streak.
    res += 1

    # Update new starting point.
    i = j

# Palindromes of alternating letters must be odd.
if res%2 == 0:
    res -= 1

# Ta da!
print(n-res)
