n = str(input()) if (n[0] == '1'): for i in range(1, len(n)): if n[i] == '3': print(len(n)-1) else:print(-1) else: print(-1)