

import java.util.Scanner;


public class Clockwork {


    public static void main(String[] args) {
        Scanner  sc = new Scanner(System.in);
        
        String digits = sc.nextLine();
        int n = digits.length();
        if (digits.charAt(0) == '0') {
            System.out.println("-1");
        } else {
            
            long best = Long.parseLong(digits, 2);
            int i = 0;
            
            boolean found = false;
            
            while (!found) {
                i++;
                
                long tmpBest = best;
                int bestBitCount = Long.bitCount(tmpBest);
                
                for (int K = 1; K <= n; K++) {
                    
                    long tmp = best >> K;
                    tmp |= best;
                    int tmpBitcount = Long.bitCount(tmp);
                    
                    if (tmpBitcount == n) {
                        System.out.println(i);
                        found = true;
                        break;
                    }
                    
                    if (tmpBitcount > bestBitCount) {
                        bestBitCount = tmpBitcount;
                        tmpBest = tmp;
                    }
                }
                
                best = tmpBest;
            }
        }
    }
    
}
