import sys N = input() if N[0] != '1': print(-1) exit() for i in range(1,len(N)): if N[i] != '3': print(-1) exit() if len(N) == 1: print(-1) exit() print(len(N)-1)