Megumin is trying to deactivate a security system! The security system is composed of exploding the whole thing flipping the switches with her staff to avoid detection! However, given her position, she can only use her staff to flip a prefix of the switches (switches
Input Specification
The first line will contain an integer
The next line will contain a string of 0
and 1
, representing the states of the switches from 0
is off, 1
is on).
Output Specification
Output the minimum number of clicks required to fully deactivate the system.
Sample Input
4
1001
Sample Output
3
Explanation for Sample Output
Megumin can use her staff to flip the first 3 switches, changing the states to 0111
.
Then she can flip all the switches, changing the states to 1000
.
Finally, she can use her staff to flip the first switch, changing the states to 0000
and fully deactivating the system.
Comments