from sys import stdin line = list(stdin.readline().strip()) if line[0] == '0': print(-1) else: relocations = 0 #print(line) while(line.count('1') != len(line)): zeros = [[] for _ in range(len(line))] shifts = [0] * len(line) for i, char in enumerate(line): if char == '0': for j in range(0, i): if line[j] == '1': zeros[i].append(i-j) shifts[i-j] += 1 max_shift = max_i = 0 for i, shift in enumerate(shifts): if shift > max_shift: max_shift = shift max_i = i new_line = line[:] for i in range(len(line) - max_i): if line[i] == '1': new_line[i + max_i] = '1' line = new_line relocations += 1 #print(line) print(relocations)