#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <functional>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
#include <math.h>
#include <random>
#include <chrono>
#include <assert.h>
using namespace std ;
using ll = long long ;
using ld = long double ;
template<class T> using V = vector<T> ;
template<class T> using VV = V<V<T>> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end()
ll mod = 1000000007 ;
long double pie = acos(-1) ;
ll INF = 1e18 ;

void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
ll extGCD(ll a,ll b,ll &x,ll &y){
    if(b==0){
        x = 1 ;
        y = 0 ;
        return a ;
    }
    ll d = extGCD(b,a%b,y,x) ;
    y -= a/b*x ;
    return d ;
}
void fix_cout(){cout << fixed << setprecision(20) ;}
template<class T> void chmax(T &a,T &b){if(a<b) a = b ;}
template<class T> void chmin(T &a,T &b){if(a>b) a = b ;}

int main(){
    ll a,b ;
    cin >> a >> b ;
    ll sub = 1 ;
    if(a==1){
        if(b==1){
            cout << 2 << endl ;
            return 0 ;
        }
        sub = 2 ;
        a++ ;
    }
    V<ll> p = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71} ;
    V<ll> dp(1<<(p.size()+1),0) ;
    int rem = 0 ;
    for(int i=0;i<p.size();i++) if(a%p[i]==0) rem |= 1<<i ;
    if(rem==0) rem += 1<<(p.size()) ;
    dp[0] = dp[rem] = 1 ;
    for(int i=1;i<b-a+1;i++){
        auto pre = dp ;
        rem = 0 ;
        for(int j=0;j<p.size();j++) if((a+i)%p[j]==0) rem |= 1<<j ; 
        for(int j=0;j<dp.size();j++){
            if((rem&j)==0) dp[j+rem] += pre[j] ;
        }
    }
    ll ans = 0 ;
    for(int i=0;i<dp.size();i++){
        ans += dp[i] ;
    }
    cout << ans*sub << endl ;

}

#include <bits/stdc++.h>

#define ln                 '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (__typeof(to) i = 0; i < to; ++i)
#define cont(i, to)        for (__typeof(to) i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (__typeof(to) i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 74;
const int hsz = int(1e7) + 39, esz = 2e6;
bitset<nsz> g[nsz + 5];
int vis[nsz + 5], pw[nsz + 5];
num n, fm, to, ans = 1, a[nsz + 5];

struct hash_table {
	int sz, hd[hsz + 5];
	
	struct node {
		int nxt;
		bitset<nsz> w;
		
		node() {}
		node(int nxt, bitset<nsz> w): nxt(nxt), w(w) {}
	} e[esz + 5];
	
	int inline to_key(const bitset<nsz> &w) {
		int u = 0;
		cont (i, n) u = (u * 2 + w[i]) % hsz;
		return u;
	}
	
	void inline ins(const bitset<nsz> &w, int u) {
		e[++sz] = node(hd[u], w), hd[u] = sz;
	}
	
	bool inline qry(const bitset<nsz> &w, int u) {
		for (int i = hd[u]; i; i = e[i].nxt) {
			if (e[i].w == w) return 1;
		}
		return 0;
	}
};
hash_table dat;

num gcd(num a, num b) {
	return !b ? a : gcd(b, a % b);
}

void bfs(int s, int &sz, int *nd) {
	static int q[nsz + 5];
	int ql = 0, qr = 0;
	for (q[qr++] = s, vis[s] = s; ql != qr;) {
		int u = q[ql++];
		nd[sz++] = u;
		cont (v, n) if (g[u][v] && !vis[v]) q[qr++] = v, vis[v] = s;
	}
}

num inline calc(int s) {
	static int nd[nsz + 5], d[esz + 5];
	static bitset<nsz> q[esz + 5], p[esz + 5];
	int sz = 0, ql = 0, qr = 1, cnt = 0;
	bfs(s, sz, nd);
	if (sz == 1) return 2;
	for (; ql != qr; ++cnt) {
		bitset<nsz> cur = q[ql], ban = p[ql], nban;
		int key = d[ql]; ++ql;
		loop (i, sz) if (!ban[nd[i]]) {
			int v = nd[i], nkey = (key + pw[v]) % hsz;
			cur[v] = 1, nban = ban | g[v];
			if (!dat.qry(cur, nkey)) {
				q[qr] = cur, p[qr] = nban, d[qr] = nkey; ++qr;
				dat.ins(cur, nkey);
			}
			cur[v] = 0;
		}
	}
	return cnt;
}

void inline init() {
	pw[0] = 1;
	cont (i, n) pw[i] = pw[i - 1] * 2 % hsz;
}

int main() {
	scanf("%lld%lld", &fm, &to);
	n = to - fm + 1;
	circ (i, fm, to) a[num(i) - fm + 1] = i;
	cont (u, n) cont (v, u) g[u][v] = g[v][u] = gcd(a[u], a[v]) > 1;
	init();
	cont (u, n) if (!vis[u]) ans *= calc(u);
	printf("%lld\n", ans);
}