a = int(input()) b = int(input()) for i in range(a, b + 1): count = 0 for j in range(2, i): if i % j == 0: count += 1 if count == 0: s1 = str(i) s2 = s1[::-1] if s1 == s2: print(i)