#C7223. Traffic Lights Synchronization

    ID: 51071 Type: Default 1000ms 256MiB

Traffic Lights Synchronization

Traffic Lights Synchronization

You are given a row of traffic lights. Each traffic light is either green (denoted by 'G') or red (denoted by 'R'). In one operation, you can flip the state of a contiguous segment of traffic lights, turning all 'G's into 'R's or all 'R's into 'G's.

Your task is to determine the minimum number of operations required to make all the traffic lights have the same color.

It can be proven that the minimum number of operations is equal to \( \min(\text{number of contiguous segments of } G, \text{number of contiguous segments of } R) \).

Input/Output Format: The input consists of two lines. The first line contains an integer \( n \) representing the number of traffic lights. The second line contains a string of length \( n \) consisting only of the characters 'G' and 'R'. Output a single integer—the minimum number of operations required.

inputFormat

The first line contains an integer \( n \) (the number of traffic lights). The second line contains a string of length \( n \) containing only the characters 'G' and 'R'.

outputFormat

Output a single integer representing the minimum number of operations required to make all the traffic lights have the same color.

## sample
5
GRGRG
2

</p>