x = input() def a(): if x[0] != '1': return -1 for a in x[1:]: if a!='3': return -1 return len(x)-1 print(a())