a = int(input())
b = int(input())
c = 0
if b > a:
for i in range(a, b + 1):
if (i**3) % 4 == 0 or (i**3) % 9 == 0:
c += 1
elif b == a:
if (a**3) % 4 == 0 or (a**3) % 9 == 0:
c += 1
print(c)
sum(1 for x in range(a, b + 1) if x ** 3 % 10 in {4, 9})
sum(1 for x in range(a, b + 1) if str(x ** 3).endswith(('4', '9')))