#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ull=unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

ll GCD(ll a,ll b){ return b?GCD(b,a%b):a; }

ll A,B;
int E[73][73];

int pN;
int I[38];
ll G[38];
int dp1[1<<19], dp2[1<<19];
ll solve(){
  rep(i,pN) G[i]=0;
  rep(i,pN) rep(j,pN) if(!E[I[i]][I[j]]) G[i]|=(1ll<<j);
  int N1=(pN+1)/2, N2=pN/2;
  ll N1mask = (1ll<<N1)-1;
  rep(i,1<<N1) dp1[i]=0;
  rep(i,1<<N2) dp2[i]=0;
  dp1[0]=dp2[0]=1;
  rep(d,N1) rep(p,1<<N1) if(!(p&(1<<d))) if(!(p&G[d])) dp1[p|(1<<d)]+=dp1[p];
  rep(d,N2) rep(p,1<<N2) if(!(p&(1<<d))) if(!(p&(G[d+N1]>>N1))) dp2[p|(1<<d)]+=dp2[p];
  rep(d,N2) rep(p,1<<N2) if(!(p&(1<<d))) dp2[p|(1<<d)]+=dp2[p];
  ll ans=0;
  rep(p,1<<N1){
    ll mask = (1ll<<N2)-1;
    rep(d,N1) if(p&(1ll<<d)) mask &= ~(G[d]>>N1);
    ans += dp1[p]*dp2[mask];
  }
  return ans;
}

ll solve2(int x){
  int N1=(pN+1)/2, N2=pN/2;
  ll N1mask = (1ll<<N1)-1;
  ll allMask = 0; rep(d,pN) if(!E[I[d]][x]) allMask |= (1ll<<d);
  ll ans=0;
  rep(p,1<<N1) if(!(p&allMask)){
    ll mask = (1ll<<N2)-1;
    mask &= ~(allMask>>N1);
    rep(d,N1) if(p&(1ll<<d)) mask &= ~(G[d]>>N1);
    ans += dp1[p]*dp2[mask];
  }
  return ans;
}

int main(){
  cin>>A>>B;
  int N = B-A+1;
  rep(i,N) rep(j,N) E[i][j]=((GCD(A+i,A+j)==1)?1:0);

  pN=0;
  rep(i,N) if((A+i)%2==1) I[pN++]=i;
  ll ans = solve();
  rep(i,N) if((A+i)%2==0) ans += solve2(i);
  cout<<ans<<endl;
  return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <chrono>
#include <random>
#include <unordered_set>

using namespace std;

typedef long long ll;

void solve() {
    ll a, b;
    cin >> a >> b;
    int n = 73;
    vector<int> s(n);
    vector<int> prime;
    for (int i = 2; i < n; i++) {
        if (s[i] == 0) {
            s[i] = i;
            prime.emplace_back(i);
            for (int j = i; j < n; j += i) {
                s[j] = i;
            }
        }
    }

    int m = b - a + 1;
    n = prime.size();
    vector<int> mask(m);

    for (int i = 0; i < m; i++) {
        ll x = a + i;
        for (int j = 0; j < n; j++) {
            if (x % prime[j] == 0) {
                mask[i] ^= (1 << j);
            }
        }
    }

    vector<ll> dp(1 << n);
    dp[0] = 1;

    for (int i = 0; i < m; i++) {
        vector<ll> dp2(1 << n);
        for (int j = 0; j < (1 << n); j++) {
            if (dp[j] == 0)
                continue;
            dp2[j] += dp[j];
            if ((mask[i] & j) == 0)
                dp2[mask[i] ^ j] += dp[j];
        }
        dp.swap(dp2);
    }

    ll ans = 0;
    for (int i = 0; i < (1 << n); i++) {
        ans += dp[i];
    }

    cout << ans;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#if defined(_DEBUG)
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int q = 1;
    //cin >> q;
    for (; q > 0; q--) {
        solve();
        //cout << endl;
    }
}