/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
// #include <bitset>
// #include <cmath>
//#include <set>
#include <iostream>
#include <unordered_set>
bool fl2(const char& c);
bool fl3(const std::string& s);
bool fl4(unsigned long long & ull);
bool fl5(const char & c);
bool fl6(const char & c,const std::string& s);
bool fl7 (unsigned long long & ull);
bool fl8(unsigned long long & ull);
bool fl9(const std::string& s);
using namespace std;
int main()
{ int j=0;
unsigned long long l,r;
cin>>l>>r;
for (unsigned long long i=l; i<=r; i++){
bool fl=1;
string str=to_string(i);
unordered_set<char> usstr(str.begin(),str.end());
if(usstr.find('0') != usstr.end()) {continue;}
if(usstr.find('9') != usstr.end()) {usstr.erase('3');}
if(usstr.find('8') != usstr.end()) {usstr.erase('4');usstr.erase('2');}
if(usstr.find('6') != usstr.end()) {usstr.erase('3');usstr.erase('2');}
for(const auto&x:usstr ){
size_t ix=(x-48);
switch (ix){
// case 1: goto lab;break;
case 2: if(fl2(str.back())) goto labcont; break;
case 3: if(fl3(str)) goto labcont;break;
case 4: if(fl4(i)) goto labcont;break;
case 5: if(fl5(str.back())) goto labcont;break;
case 6: if(fl6(str.back(),str)) goto labcont;break;
case 7: if(fl7(i)) goto labcont;break;
case 8: if(fl8(i)) goto labcont;break;
case 9: if(fl9(str)) goto labcont;break;
default:break;
};
// };lab: if(fl){j++; cout<<i<</*' '<<bitset<32>(i)<<*/ ',';}
};lab: if(fl){j++;} labcont:;
}
cout<<j<< endl;
cout<< endl;
return 0;
}
bool fl2(const char& c){
return c%2;
}
bool fl3(const string& s){
int sum=0;
for(const auto & x:s) sum+=x-48;
return sum%3;
}
bool fl4(unsigned long long & ull){
(ull%2)&&((ull>>1)%2);
return (ull%2)||((ull>>1)%2);
}
bool fl5(const char & c){
return ((c-48)%5);
}
bool fl6(const char & c,const string& s){
return fl2(c) || fl3(s);
}
bool fl7 (unsigned long long & ull){return ull%7;}
bool fl8(unsigned long long & ull){
(ull%2)&&((ull>>1)%2);
return (ull%2)||((ull>>1)%2)||((ull>>2)%2);
}
bool fl9(const string& s){
int sum=0;
for(const auto & x:s) sum+=x-48;
return sum%9;
}