#include<iostream>
#include<cstdio>
using namespace std;
#define ll long long
int main(void)
{
ll a,b,c,t,e;
int f,k,l,m;
while(cin>>a>>b&&(a||b)){
c = b-a+1;
f = 0;
for(int i = a;i<=b;++i){
f = m = 0;
t = e = i;
while(t>0){
f = t%10;
t /= 10;
if(f == 4)
break;
}
if(f == 4){
c -= 1;
break;
}
while(e>10){
k = e%10;
l = e%100/10;
if(l == 6&&k == 2){
m = 1;
break;
}
e = e/10;
}
if(m == 1){
c -= 1;
break;
}
}
cout<<c<<endl;
}
#include<cstdio>
using namespace std;
#define ll long long
int main(void)
{
ll a,b,c,t,e;
int f,k,l,m;
while(cin>>a>>b&&(a||b)){
c = b-a+1;
f = 0;
for(int i = a;i<=b;++i){
f = m = 0;
t = e = i;
while(t>0){
f = t%10;
t /= 10;
if(f == 4)
break;
}
if(f == 4){
c -= 1;
break;
}
while(e>10){
k = e%10;
l = e%100/10;
if(l == 6&&k == 2){
m = 1;
break;
}
e = e/10;
}
if(m == 1){
c -= 1;
break;
}
}
cout<<c<<endl;
}
return 0;}
//以上带码时间会超过
//下面代码才ok
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define ll long long
int m[1000001]={0};
void p(){
int t;
for( int i = 1;i<=1000000;++i){
t = i;
while(t>0){
if(t%10 == 4||t%100 == 62)
m[i]++;
t /= 10;
}
}
}
int main(void)
{
int a,b,t,c;
p();
while(scanf("%d%d",&a,&b) != EOF&&(a||b)){
c = b-a+1;
for(int i = a;i<=b;++i){
if(m[i] != 0)
c -= 1;
}
cout<<c<<endl;
}
return 0;}
链接http://acm.hdu.edu.cn/showproblem.php?pid=2089