a = int(input()) for i in range(2, 100): n = a ans = '' while n: q = n % i n = n // i ans = str(q) + ans if ans == '17': print(i) break else: print('-1')