#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];
int dp3[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){
    int mask = (1ll<<N2)-1;
    rep(d,N1) if(p&(1ll<<d)) mask &= ~(G[d]>>N1);
    dp3[p] = mask;
    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 = dp3[p] & ~(allMask>>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;
}

#include <cstdio>
#include <cassert>
long long A,B,ans,tmp;
long long a[105];
long long g[105][105];
bool fp[105];
long long gcd(long long a,long long b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}
void dfs(long long now,int p)
{
    if(now==B+1)
    {
        ans++;
        return;
    }
    dfs(now+1,p);
    if(!fp[now-A])
    {
        for(int i=0;i<p;i++)
        {
            if(g[now-A][a[i]-A]!=1)
                return;
        }
        a[p]=now;
        dfs(now+1,p+1);
    }
}
int main()
{
    scanf("%lld%lld",&A,&B);
    for(long long i=A;i<=B;i++)
        for(long long j=A;j<=B;j++)
            g[i-A][j-A]=gcd(i,j);
    for(long long i=A;i<=B;i++)
    {
        fp[i-A]=true;
        for(long long j=A;j<=B;j++)
            if(i!=j&&g[i-A][j-A]!=1)
            {
                fp[i-A]=false;
                break;
            }
    }
    tmp=1;
    for(long long i=A;i<=B;i++)
        if(fp[i-A])
            tmp*=2;
    dfs(A,0);
    printf("%lld\n",ans*tmp);
    return 0;
}
