n = int(input())
for i in range(1000, n + 1):
    q = i // 1000 % 10
    b = i // 100 % 10
    s = i // 10 % 10
    g = i // 1 % 10
    if q == s and b == g and i % 2 == 1:
        print(i)

/**************************************************************
	Problem: 1737
	User: admin
	Language: Python
	Result: Accepted
	Time:111 ms
	Memory:34480 kb
****************************************************************/