#C8006. Minimum Operations to Open All Doors

    ID: 51941 Type: Default 1000ms 256MiB

Minimum Operations to Open All Doors

Minimum Operations to Open All Doors

You are given a string doors consisting of the characters '0' and '1' where each character represents a door: '0' indicates that the door is closed and '1' indicates that it is open. The goal is to open all the doors (i.e. they should all be '1') using a minimum number of operations.

You process the string from left to right. Initially, the desired state for a door is '1'. When you encounter a door whose state does not match the expected value, you perform an operation. If the expected value is '1' (i.e. the door should be open) but the door is closed, you not only flip that door but also change the expectation for all subsequent doors (i.e. the expected state is toggled). Otherwise, if the door is open when the expected state is '0', you only flip that single door without changing the expected state.

For an empty string, output 0 operations.

Your task is to compute the minimum number of operations required to eventually have every door open.

Note: All operations are simulated via toggling as described above.

inputFormat

The input consists of a single line containing a non-empty string (or possibly an empty string) of characters '0' and '1', representing the initial state of the doors.

You should read the input from the standard input (stdin).

outputFormat

Output a single integer — the minimum number of operations required to open all the doors. Write the result to the standard output (stdout).

## sample
000
1