n = int(input()) t = 1 while True: l = list(str((t*10+1)*n)) l = l[:-1] mode = True for i in range(len(l)//2): if l[i] != l[-i-1]: mode = False if mode: print((t*10+1)*n) quit() t += 1