#include <iostream>
#include <vector>
using namespace std;

int main()
{
    long long A, B;
    cin>>A>>B;

    vector<int> F;
    for (int f=2; f<=72; f++)
    {
        bool ok = true;
        for (int i=2; i<f; i++)
            if (f%i==0)
                ok = false;
        if (ok)
            F.push_back(f);
    }
    int n = (int)F.size();

    vector<long long> T(1<<n);
    T[0] = 1;

    for (long long c=A; c<=B; c++)
    {
        vector<long long> P = T;
        int b = 0;
        for (int i=0; i<n; i++)
            if (c%F[i]==0)
                b |= 1<<i;

        for (int i=0; i<1<<n; i++)
            if ((b&i)==0)
                T[b|i] += P[i];
    }
    long long ans = 0;
    for (long long t: T)
        ans += t;
    cout<<ans<<endl;
}

#include <bits/stdc++.h>
using namespace std;

#define ll long long

ll gcd(ll x,ll y) {
  return x==0 ? y : gcd(y%x,x);
}

const int M = 19;
const int BIT = (1<<M);

int cc[BIT],op[BIT],cc2[BIT],dp[BIT];

void solve2() {
  ll x,y;
  cin>>x>>y;
  ll ret = 0;
  if(y-x+1<=10) {
    ll v[10];
    for(ll i=x;i<=y;++i) {
      v[i-x] = i;
    }
    int len = y-x+1,B = (1<<len);
    for(int bit=0;bit<B;++bit) {
      bool isGood = true;
      for(int i=0;i<len && isGood;++i) {
        if(bit&(1<<i)) {
          for(int j=0;j<len;++j) {
            if( (bit&(1<<j)) && j!=i) {
              if(gcd(v[j],v[i])!=1) {
                isGood = false;
                break;
              }
            }
          }
        }
      }
      ret += isGood;
    }
  } else {
    ll even[50];
    int e_pos = 0;
    even[e_pos++] = 1;
    vector<ll> v[2];
    for(ll i=x;i<=y;++i) {
      if(i%2==0) {
        even[e_pos++] = i;
      } else {
        v[v[0].size()<M ? 0 : 1].push_back(i);
      }
    }
    vector<pair<int,int> > g;

    for(int i=0;i<v[0].size();++i) {
      int bit = 0;
      for(int j=0;j<v[0].size();++j) {
        if(i!=j && gcd(v[0][j],v[0][i])!=1) {
          bit |= (1<<j);
        }
      }
      int bit2 = 0;
      for(int j=0;j<v[1].size();++j) {
        if(gcd(v[1][j],v[0][i])!=1) {
          bit2 |= (1<<j);
        }
      }
      g.push_back({bit,bit2});
    }
    int B = (1<<v[0].size());
    for(int bit=0;bit<B;++bit) {
      bool isGood = true;
      for(int i=0;i<v[0].size();++i) {
        if(bit&(1<<i)) {
          isGood &= (g[i].first&bit) ==0;
          op[bit] |= g[i].second;
        }
      }
      cc[bit] = isGood ? 1 : 0;
    }
    g.clear();
    for(int i=0;i<v[1].size();++i) {
      int bit = 0;
      for(int j=0;j<v[1].size();++j) {
        if(i!=j && gcd(v[1][j],v[1][i])!=1) {
          bit |= (1<<j);
        }
      }
      g.push_back({bit,0});
    }

    int B2 = (1<<v[1].size());
    for(int bit=0;bit<B2;++bit) {
      bool isGood = true;
      for(int i=0;i<v[1].size();++i) {
        if(bit&(1<<i)) {
          isGood &= (g[i].first&bit) ==0;
        }
      }
      cc2[bit] = isGood ? 1 : 0;
    }

    for(int iter=0;iter<e_pos;++iter) {
      ll cur_value = even[iter];
      memset(dp,0,sizeof(dp));
      int bit1 = 0,bit2=0;
      for(int i=0;i<v[0].size();++i) {
        if(gcd(cur_value,v[0][i])!=1) bit1 |= (1<<i);
      }
      for(int i=0;i<v[1].size();++i) {
        if(gcd(cur_value,v[1][i])!=1) bit2 |= (1<<i);
      }
      for(int bit=0;bit<B2;++bit) {
        dp[bit] = cc2[bit] >0 && ( (bit&bit2)==0);
      }
      for(int b=0;b<v[1].size();++b) {
        for(int bit=0;bit<B2;++bit) {
          if(bit&(1<<b)) {
            dp[bit] += dp[bit^(1<<b)];
          }
        }
      }
      int x = B2-1;
      for(int bit=0;bit<B;++bit) {
        if(bit&bit1) continue;
        if(cc[bit]==0) continue;
        ret += dp[x^op[bit]];
      }
    }
  }
  printf("%lld\n", ret);
}

void solve() {
    solve2();
}

inline bool exists_test0 (const std::string& name);
inline bool exists_test1 (const std::string& name);
int main() {
#ifdef LOCAL
  string file_name = "input.txt";
  assert(exists_test0(file_name));
  assert(exists_test1(file_name));
  freopen("input.txt","r",stdin);
#endif
  solve();
  return 0;
}

/*
0. Enough array size? Enough array size? Integer overflow?

1. Think TWICE, Code ONCE!
Are there any counterexamples to your algo?

2. Be careful about the BOUNDARIES!
N=1? P=1? Something about 0?

3. Do not make STUPID MISTAKES!
Time complexity? Memory usage? Precision error?

4. Be careful to use wrong variable.
*/
inline bool exists_test0 (const std::string& name) {
    ifstream f(name.c_str());
    return f.good();
}

inline bool exists_test1 (const std::string& name) {
    if (FILE *file = fopen(name.c_str(), "r")) {
        fclose(file);
        return true;
    } else {
        return false;
    }
}
