cswork / OAOpen practice workspace

IBMOA #62

Minimum Operations to Make Alternating Binary String

Estimated EasyJudge-ready

Topics (AI-labelled)Strings

Each operation flips one bit; make all adjacent characters different and find the minimum number of flips. The empty string already satisfies the condition. The source statement body is missing; the operation was recovered from the title and the original example's bit-by-bit flip explanation. In the original example, flipping the 1st and 3rd bits (1-indexed) of 111101 gives 010101, so the answer is 2; the 101010 written in the original example is a typo for the target string.

Input

The first line contains the length n, and the second line contains the binary string (an empty line when n=0). Full original bounds: 0≤n≤200000, and the string contains only 0 and 1.

Output

Output one integer, the answer.

Example 1

Input:

5
11101

Output:

1

Example 2

Input:

6
111101

Output:

2

Example 3

Input:

0

Output:

0

Example notes

The outputs of the three public examples are, in order: 1; 2; 0. These answers were verified by independent enumeration or direct simulation.

Editorial

Loading solution…