N=int(input()) M=10**9//N*N+N while M%10<9:M+=N D=M//N//10 import random s="12" while s!="".join(reversed(s)):M=(random.randint(D,max(10*6,D*9))*10+1)*N;s=str(M)[:-1] print(M)