while True:
n, m = map(int, input().split())
if n == 0 and m == 0:
break
count = 0
for i in range(n, m+1):
if '4' in str(i) or '62' in str(i):
continue
count += 1
print(count)
while True:
n, m = map(int, input().split())
if n == 0 and m == 0:
break
count = 0
for i in range(n, m+1):
if '4' in str(i) or '62' in str(i):
continue
count += 1
print(count)
while True:
n, m = map(int, input().split())
if n == 0 and m == 0:
break
count = 0
for i in range(n, m+1):
if '4' in str(i) or '62' in str(i):
continue
count += 1
print(count)