import sys, time, random, heapq, math, itertools, copy from collections import deque, Counter, defaultdict from bisect import bisect, bisect_left, bisect_right import heapq as hq from functools import cache, cmp_to_key def debug(*x):print('debug:',*x, file=sys.stderr) sys.setrecursionlimit(300000) input = lambda: sys.stdin.readline().rstrip() ii = lambda: int(input()) mi = lambda: map(int, input().split()) li = lambda: list(mi()) inf = 2 ** 61 - 1 mod = 998244353 dir = [(0, 1), (0, -1), (1, 0), (-1, 0)] N = ii() inv10 = pow(10, -1, N) t = (-9 * inv10) % N Min = 100000000 t += Min + (-Min) % N for i in range(10000000): temp = str(t) if temp == temp[::-1]: print(temp + "9") exit() t += N