a = int(input()) x = 1 while True: a_x = x ** 1 * 1 + x ** 0 * 7 if a == a_x: print(x) break elif x == 1 and a < a_x: print(-1) break else: x += 1