#GYM104763B. Jellyfish Lights
Jellyfish Lights
本题没有可用的提交语言。
Description
At the Jellyfish Aquarium, there is a tunnel with lights overhead where the jellyfish swim. Each light can be turned on ($1$) or off ($0$). To create a pleasant experience for the visitors, the lights must be arranged in an alternating pattern throughout the tunnel. However, due to some malfunction, the lights are currently in a random state.
Your task is to write a program that will find the minimum number of lights that need to be toggled to achieve the desired alternating pattern. There are two possible alternating patterns: starting with $0$ ($010101$...) or starting with $1$ $(101010...)$. Your program should consider both patterns and find the one that requires the fewest toggles.
The first line contains an integer $n$ $(1 \leq n \leq 100)$ — the number of lights in the tunnel. The second line contains a string $s$ of length $n$, representing the current state of the lights, where $s[i]$ is either 0 or 1.
Print a single integer — the minimum number of toggles needed to arrange the lights in an alternating pattern.
Input
The first line contains an integer $n$ $(1 \leq n \leq 100)$ — the number of lights in the tunnel. The second line contains a string $s$ of length $n$, representing the current state of the lights, where $s[i]$ is either 0 or 1.
Output
Print a single integer — the minimum number of toggles needed to arrange the lights in an alternating pattern.
5
01011
1
Note
In the example, toggling the last light changes the pattern to $01010$, which is an alternating pattern starting with $0$.