#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;
//using mint = modint;
 
const vector<int> dx = {1, 1,  1, 0,  0, 0, -1, -1, -1};
const vector<int> dy = {1, 0, -1, 1, -1, 0,  1,  0, -1};
const double PI = 3.141592653589793;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;
const ll mod2 = 998244353;
 
const int MAX = 1000000;
const ll MOD = 998244353;
const ll big = 1ll<<60;
 
struct edge{
  int to;
  ll cost;
};
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }

int main(){
    int l, r;
    cin >> l >> r;
    vector<ll>cnt(1001005);
    for(int i = 1001001; i>=2; i--){
      cnt[i] = 1ll*(r/i-(l-1)/i)*(r/i-(l-1)/i);
      int x = 2*i;
      while(x <= r){
        cnt[i] -= cnt[x];
        x += i;
      }
    }
    ll ans = 0;
    rep(i, 2, 1001002){
      ans += cnt[i];
      if(l<=i&&i<=r){
        ans -= 1ll*(r/i-(l-1)/i);
        ans -= 1ll*(r/i-(l-1)/i);
        ans++;
      }
    }
    cout << ans << endl;
}
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

ll solve(int L, int R){
  vector<ll> memo(1<<21, -1);
  auto f = [&](auto self, int L, int R) -> ll {
    // L < x <= R であって、gcd(x,y) == 1 となるものを数える
    auto key = L + R;
    if(memo[key] != -1) return memo[key];
    
    ll res = ll(R - L) * (R - L);
    int d = max(L, R);
    while(d > 1){
      int nxt_d = max(L / (L / d + 1), R / (R / d + 1));
      res -= (d - nxt_d) * self(self, L / d, R / d);
      d = nxt_d;
    }
    memo[key] = res;
    return res;
  };
  
  auto g = [&](int L, int R) -> ll {
    ll res = 0;
    int d = max(L, R);
    while(d){
      int nxt_d = max(L / (L / d + 1), R / (R / d + 1));
      ll cnt = max(0, min(d, R) - max(nxt_d, L));
      res += cnt * (R / d - L / d);
      d = nxt_d;
    }
    return res;
  };
  
  --L;
  ll ans = ll(R - L) * (R - L);
  ans -= f(f, L, R) + 2 * g(L, R);
  ans += 2 * (L < 1 ? R - L : 0) + (R - L);
  ans -= L < 1;
  return ans;
}

int main(){
  int L, R;
  cin >> L >> R;
  ll ans = solve(L, R);
  cout << ans << endl;
  return 0;
}  
