n=int(input())
for i in range(1,n+1):
    if len(str(i))==1:
        print(i)
    elif len(str(i))==2 or len(str(i))==3:
        if str(i)[0]==str(i)[-1]:
            print(i)
    elif len(str(i))==4 or len(str(i))==5:
        if str(i)[0] == str(i)[-1] and str(i)[1] == str(i)[-2]:
            print(i)
    else:
        if str(i)[0] == str(i)[-1] and str(i)[1] == str(i)[-2] and str(i)[2] == str(i)[-3]:
            print(i)