#C7616. Nearest Parking Spot

    ID: 51507 Type: Default 1000ms 256MiB

Nearest Parking Spot

Nearest Parking Spot

You are given a parking lot represented as a string of characters, where '1' indicates an occupied spot and '0' indicates an empty spot. The parking lot is arranged in order from the entrance. Your task is to find the index of the first available (empty) parking spot. If there is no available spot, output -1.

The problem can be formally expressed as follows:

Given a string ( s ) of length ( n ) consisting of characters '0' and '1', find the smallest index ( i ) (0-based) such that ( s[i] = '0' ). If no such ( i ) exists, return -1.

inputFormat

The input is a single line containing a non-empty string representing the parking lot. The string consists only of the characters '0' and '1'.

outputFormat

Output a single integer which is the index of the first available parking spot. If there is no available spot, output -1.## sample

100010
1