N = int(input()) x = 10 ** 9 // N a = -x % 10 + 1 x += a f = True while f: s = str(N * x) ns = len(s) - 1 for i in range(ns//2): if s[i] != s[ns-i-1]: break else: f = False x += 10 print(s)