n,m = map(int,input().split())
elt = m
sum_elt = 0
for i in range(m):
for i in str(elt):
if int(i) % 2 == 0:
sum_elt+=int(i)
if sum_elt != 0 and sum_elt % 5 == 0:
print(elt)
break
else:
if elt == n:
print(0)
elt-=1
n,m = map(int,input().split())
elt = m
sum_elt = 0
for i in range(m):
for i in str(elt):
if int(i) % 2 == 0:
sum_elt+=int(i)
if sum_elt != 0 and sum_elt % 5 == 0:
print(elt)
break
else:
if elt == n:
print(0)
break
elt-=1
sum_elt = 0