N = input() X = "1" for i in range(1,102): X += "3" if N == X: print(i) exit() print(-1)