l = list(input()) print(len(l)-1 if l[0]=='1' and set(l[1:])=={'3'} else -1)