#C7606. Minimum Flips to Zero

    ID: 51496 Type: Default 1000ms 256MiB

Minimum Flips to Zero

Minimum Flips to Zero

You are given a binary string consisting only of characters '0' and '1'. The goal is to convert the binary string into a string containing only '0's by flipping some contiguous subsegments. A flip operation inverts all bits in the chosen subsegment (i.e. changes '0' to '1' and '1' to '0').

It can be proven that the minimum number of flips needed is equal to the number of contiguous segments of '1's present in the string. In other words, if the binary string is denoted by \( s \), then the answer is given by:

[ \text{result} = #{\text{contiguous groups of } '1' \text{ in } s} ]

For example, if \( s = "1101" \) then there are 2 groups of consecutive '1's, so the answer is 2.

inputFormat

The input consists of a single line containing a binary string \( s \) composed of the characters '0' and '1'.

outputFormat

Output a single integer denoting the minimum number of contiguous subsegments that need to be flipped to make the entire string consist of only '0's.

## sample
1101
2

</p>