def is_iwi(x): if x % 10 != 9: return False xx = str(x)[:-1] return xx == xx[::-1] Ns = input() N = int(Ns) L = len(Ns) i = 10 ** L + 1 ans = N * i assert is_iwi(ans) if ans >= 10 ** 9: print(ans) exit() s = 10 ** 9 // N while True: if N * s >= 10 ** 9 and N * s % 10 == 9: break s += 1 for i in range(s, s + 10 ** 10, 10): if is_iwi(N * i): print(N * i) break