Home
Users
Problems
Contests
Posts
Submissions
FAQ
❤️
Donate
Login
Register
|
Matcom Online Grader
The 5th Cuban Programming League (Warmup)
Ended (Frozen)
Overview
Problems
Standing
Submissions
Submit
Clarifications
C - Coloring tiles
Languages:
C, C++, Java, Python, Kotlin
Time & Memory limits:
(details)
All submissions
Accepted submissions
Submit
At Fito's garden, $N$ tiles are arranged in a row. The initial color of each tile is represented by a string $S$ of length $N$. The $i$-th tile from the left is painted **black** if the $i$-th character of $S$ is $0$ and painted **white** if that character is $1$. Fito wants to repaint some of the tiles **black** or **white** so that any two adjacent tiles have different colors. What is the minimum amount of tiles that he need to repaint in order to satisfy this condition?
Input
The first line of input contains the string $S ( 1≤|S|≤10^5 )$. Each character of $S$ is either $0$ or $1$.
Output
The minimum number of tiles that Fito needs to repaint in order to satisfy the condition.
Sample test(s)
Input
Copy
000
Output
Copy
1
Input
Copy
10010010
Output
Copy
3
Input
Copy
0
Output
Copy
0
Hints
In the first example, Fito could repaint the second tile and the sequence would be $010$ (any two adjacent tiles have different colors). Therefore the minimum amount of tiles to repaint is $1$ since at least one has to be repainted because the original sequence does not satisfy the condition.