N = int(input()) k = 10 ** 9 // N while N * k % 10 != 9: k += 1 while True: q = (N * k) // 10 if (str(q) == str(q)[::-1]): print(N * k) exit() k += 10