#include <vector>
#include <iostream>

#define int         long long
#define double      long double
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;

signed main() {
    tezz
    
    vector<int> primes;
    for (int i = 2; i < 72; i++) {
        bool flag = true;
        for (int j = 2; j < i; j++) {
            if (i % j == 0) flag = false;
        }
        if (flag) primes.emplace_back(i);
    }

    int A, B;
    cin >> A >> B;
    vector<int> v(B - A + 1);
    for (int i = A; i <= B; i++) {
        int mask = 0;
        for (int j = 0; j < primes.size(); j++) {
            if (i % primes[j] == 0) {
                mask |= (1 << j);
            }
        }
        v[i - A] = mask;
    }
    
    vector<int> dp(1<<primes.size());
    dp[0] = 1;
    for (int x: v) {
        for (int mask = 0; mask < (1 << primes.size()); mask++) {
            if (dp[mask]) {
                int tmp = mask & x;
                if (tmp == 0) dp[mask | x] += dp[mask];
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < (1 << primes.size()); i++) ans += dp[i];
    cout << ans;
}
#include<cstdio>
#define N 300001
using namespace std;
long long m2[N],m3[N],m5[N],m7[N],go[N],used[N];
long long s[101][101];
long long n,m,ans=0;
long long gcd(long long x,long long y)
{
	if (x==1||y==1) return 1;
	return s[x-n+1][y-n+1];
}
long long gcd1(long long x,long long y)
{
	if (y==0) return x;
	return gcd1(y,x%y);
}
void dfs(int k)
{
	if (k>used[0]) 
	{
		ans++;
		return;
	}//ans++;
	dfs(k+1);
	bool bo=true;
	for (int i=1;i<=go[0];i++)
		if (gcd(go[i],used[k])!=1)
		{
			bo=false;break;
		}
	if (bo)
	{
		go[++go[0]]=used[k];
		dfs(k+1);
		go[0]--;
	}
}
int main()
{
	scanf("%lld%lld\n",&n,&m);
	m2[0]=1;m3[0]=1;m5[0]=1;m7[0]=1;
	m2[1]=1;m3[1]=1;m5[1]=1;m7[1]=1;
	for (long long i=n;i<=m;i++)
		for (long long j=n;j<=m;j++)
			s[i-n+1][j-n+1]=gcd1(i,j);
	long long pans=1;
	for (long long i=n;i<=m;i++)
	{
		if (i%2==0)
			m2[++m2[0]]=i;
		else
			if (i%3==0) m3[++m3[0]]=i;
			else if (i%5==0) m5[++m5[0]]=i;
			else if (i%7==0) m7[++m7[0]]=i;
			else	
			{
				bool bo=true;
				for (long long j=n;j<=m;j++)
				{
					if (i==j) continue;
					if (s[i-n+1][j-n+1]!=1)
					{
						bo=false;break;
					}
				}
				if (!bo||(i*2<=m))
					used[++used[0]]=i;
				else	pans*=2;
			}
	}
	ans=0; 
	for (int i=1;i<=m2[0];i++)
	{
		for (int j=1;j<=m3[0];j++)
		{
			if (gcd(m2[i],m3[j])!=1) continue;
			for (int k=1;k<=m5[0];k++)
			{
				if (gcd(m2[i],m5[k])!=1) continue;
				if (gcd(m3[j],m5[k])!=1) continue;
				for (int p=1;p<=m7[0];p++)
				{
					if (gcd(m2[i],m7[p])!=1) continue;
					if (gcd(m3[j],m7[p])!=1) continue;
					if (gcd(m5[k],m7[p])!=1) continue;
					go[0]=4;
					go[1]=m2[i];go[2]=m3[j];go[3]=m5[k];go[4]=m7[p];
					dfs(1);
				//	printf("%d %d %d %d\n",m2[i],m3[j],m5[k],m7[p]);
				//	printf("%lld\n",ans);
				}
			}
		}
	}
	printf("%lld\n",ans*pans);
}