n = str(input()) if (n[0] == '1') and (n[1:-1] == '3'): print(len(n)-1) else: print(-1)