#include <assert.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <map>

using namespace std;

#define all(x) x.begin(), x.end()

const long long mod = (long long) (1e9 + 7);


long long powerf(long long a, long long b, long long c = mod) {
	long long res = 1;
	while (b > 0) {
		if (b%2 != 0)
			res = (res * a) % c;
		b/=2;
		a = (a * a) % c; 
	}
	return res;
}

template<class T>
T gcd(T a, T b) {
	return (a == 0 ? b : gcd(b%a, a));
}


const int N = (int)(1e6 + 6);
vector<long long> mul(N, 0);
vector<long long> tmp1(N, 0);
long long nonCoPrimes = 0;
long long L, R;

auto nc2 = [](long long x) {
	return (x * (x - 1)) / 2;
};

void init() {
	for (long long x = 2; x < N; x++) {
		for (long long y = x; y < N; y+=x) {
			if (y >= L && y <= R)
				mul[x]++;
		}
	}

	for (long long x = N-1; x >= 2; x--) {
		long long cur = 0;
		cur = nc2(mul[x]);
		for (long long y = 2*x; y < N; y+=x) {
			cur -= tmp1[y];
		}
		tmp1[x] = cur;
		nonCoPrimes += tmp1[x];
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	

	cin >> L >> R;
	init();
	long long completelyDivPairs = 0;

	for (long long x = max(L, 2LL); x <= R; x++) {
		completelyDivPairs += mul[x] - 1;
	}

	cout << 2 * (nonCoPrimes - completelyDivPairs) << "\n"; 
	return 0;
}



#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

ll x,y;
unordered_map<ll,ll> um;

ll solve(ll num){
    if(num==1) return abs(x-num);
    if(um.find(num)!=um.end()) return um.find(num)->second;
    ll result;
    if(num%2) result = min(abs(x-num),min(solve((num+1)/2)+2,solve((num-1)/2)+2));
    else result = min(abs(x-num),solve(num/2)+1);
    um.insert({num,result});
    return result;
}
int main(void){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    cin >> x >> y;
    cout << solve(y);
    return 0;
}