#include <bits/stdc++.h>
using namespace std;
long long INF = 1000000000000000000;
int main(){
    long long A, B;
    cin >> A >> B;
    vector<long long> d;
    for(int i = 2; i <= 72; i++){
        if(i == 2) d.push_back(i);
        if(i % 2 == 0) continue;
        bool flag = true;
        for(int j = 2; j * j <= i; j++){
            if(i % j == 0) flag = false;
        }
        if(flag) d.push_back(i);
    }
    int L = d.size();
    vector<vector<long long>> dp((B - A + 2), vector<long long>(1 << L));
    int ind = 0;
    dp[0][0] = 1;
    for(long long i = A; i <= B; i++){
        long long bit = 0;
        for(int k = 0; k < L; k++){
            if(i % d[k] == 0) bit |= (1 << k);
        }
        for(int j = 0; j < (1 << 20); j++){
            if((j & bit) == 0) dp[ind + 1][j | bit] += dp[ind][j];
            dp[ind + 1][j] += dp[ind][j];
        }    
        ind++; 
    }
    long long ans = 0;
    for(int i = 0; i < (1 << L); i++) ans += dp[B - A + 1][i];
    cout << ans << endl;
}
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define pii pair<ll,ll>
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define autoitr(x,it) for(auto it = x.rbegin(); it != x.rend(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

vector<vector<ll>> g;

ll powa[64];

ll get(vector<ll> &v)
{
    ll n = v.size();
    if(n<2)
        return n;
    ll fst = (n+1)/2, sec = n/2;
    vector<ll> v1,v2;
    rep(n)
        if(i<fst)
            v1.pb(v[i]);
        else v2.pb(v[i]);    
    ll self1[fst], self2[sec], cross[fst];
    rep(fst)
        self1[i] = powa[fst] - 1;
    rep(sec)    
        self2[i] = powa[sec] - 1;
    rep(fst)
        cross[i] = powa[sec] - 1;
    for(ll i=0;i<fst;i++)
        for(ll j=0;j<fst;j++)
        {
            if(i != j && __gcd(v1[i],v1[j]) > 1)
                self1[i]-=powa[j];
        }
     for(ll i=0;i<sec;i++)
        for(ll j=0;j<sec;j++)
        {
            if(i != j && __gcd(v2[i],v2[j]) > 1)
                self2[i]-=powa[j];
        }    
    for(ll i=0;i<fst;i++)
        for(ll j=0;j<sec;j++)
        {
            if(__gcd(v1[i],v2[j]) > 1)
                cross[i]-=powa[j];
        }      
    vector<ll> s1, s2;    
    for(ll mask=1;mask<powa[fst];mask++)
    {
        ll allowed = powa[fst] - 1;
        for(ll j=0;j<fst;j++)
            if(powa[j]&mask)
                allowed&=self1[j];
        if((mask&allowed) != mask)
            continue;
        s1.pb(mask);    
    }
    
    for(ll mask=1;mask<powa[sec];mask++)
    {
        ll allowed = powa[sec] - 1;
        for(ll j=0;j<sec;j++)
            if(powa[j]&mask)
                allowed&=self2[j];
        if((mask&allowed) != mask)
            continue;
        s2.pb(mask);
    }
    
    ll dp[sec+1][powa[sec]];
    memset(dp,0,sizeof(dp));
    for(auto &x : s2)
        dp[sec][x] = 1;
    for(ll bit=sec-1;bit>-1;bit--)    
    {
        for(ll mask=0;mask<powa[sec];mask++)
        {
            if(powa[bit]&mask)
                dp[bit][mask]+=(dp[bit+1][mask] + dp[bit+1][mask^powa[bit]]);
            else dp[bit][mask]+=(dp[bit+1][mask]);    
        }
    }
    
    ll ans = 0;
    for(auto &x : s1)
    {
        ll allowed = powa[sec] - 1;
        for(ll j=0;j<fst;j++)
            if(powa[j]&x)
                allowed&=cross[j];
        ans+=dp[0][allowed];     
    }
    
    ans+=((ll)s1.size());
    ans+=((ll)s2.size());
    return ans;
}

int main()
{
  FAST/**/
  
  powa[0] = 1;
  for(ll i=1;i<64;i++)
      powa[i] = powa[i-1]*2;
  
  ll a,b;
  cin>>a>>b;
  
  vector<ll> even;
  vector<ll> nums;    
  for(ll i=a;i<=b;i++)
        if(i%2 == 0)
            even.pb(i);
        else nums.pb(i);    
  
  ll ans = 1;
  ans+=get(nums);
  
  for(ll i=0;i<even.size();i++)            
  {
      vector<ll> v1;
      for(ll j=0;j<nums.size();j++)
      {
          if(__gcd(nums[j], even[i]) == 1)
                v1.pb(nums[j]);
      }
      ans+=(1ll + get(v1));
  }
  
  cout<<ans<<'\n';
  
  return 0;
}
   
   
 