Олимпиадный тренинг

Задача 38204. Slippers


Задача

Темы: Перебор
In my hallway there are 20 slippers in a row – 10 left and 10 right. Coming home, I change my shoes and choose two slippers – left and right, in which it is most convenient for me to stick my legs. Naturally, the left slipper should be to the left of the right one, and the distance (number of other slippers) between them should be as small as possible. Write a program that calculates how many slippers are between the ones I feel most comfortable wearing.

Input
A sequence of 10 zeros and 10 ones is entered, written in some order. The unit corresponds to the left slipper, 0 – right slipper. Numbers are separated by spaces.
Imprint
The program should print the number of slippers between the most comfortable slippers, or -1 if there are none.
 
Examples
# Input Output
1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0