N = input() if N[0] == '1' and N[1] == '3' and len(set(N)) == 2: print(len(N)-1) else: print(-1)