n,m = [int(a) for a in input().split()]
avg = (n+m)//2
lis = []
for i in range(avg,m):
    if str(i) == str(i)[::-1]:
        lis.append(i)
        break
##for a in range(avg):
##    if str(a) == str(a)[::-1] and a != 0:
##        lis.append(a)
##        break
newLis = []
for i in lis:
    newLis.append(
print(choice)
