#include <bits/stdc++.h>

using namespace std;

constexpr int N = 1000000;

bool is_radical[N + 1];
bool prime[N + 1];
int pf[N + 1];

int main() {
	long long cur, ans, l, r, n, d;

	scanf("%lld%lld", &l, &r);

	memset(is_radical, true, sizeof(is_radical));
	memset(prime, true, sizeof(prime));
	prime[0] = prime[1] = false;
	ans = 0;

	for (d = 2; d <= r; d++) {
		cur = 0;

		for (n = d; n <= r; n += d) {
			if (prime[d]) {
				pf[n]++;

				if (n > d) {
					prime[n] = false;
				}
			}

			if (l <= n and n <= r) {
				cur++;

				if (n > d and l <= d and d <= r) {
					ans -= 2;
				}
			}
		}

		for (n = d * d; n <= r; n += d * d) {
			is_radical[n] = false;
		}

		if (is_radical[d]) {	
			if (pf[d] % 2) {
				ans += cur * (cur - 1);
			}
			else {
				ans -= cur * (cur - 1);
			}
		}
	}

	printf("%lld\n", ans);

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

typedef long long ll;
typedef pair<int,int> ii;

ll x;
map<ll, ll> sv;

ll f(ll y){
	if (sv.find(y) != sv.end()) return sv.find(y)->second;
	sv[y] = 0LL;
	ll &ans = sv[y];
	if (y>x){
		if (y&1){
			ll ri = (y+1LL);
			ll le = (y-1LL);
			ll directtarget = y-x;
			return ans = min(f(ri)+1LL, min(f(le)+1LL, f(x)+directtarget));
		}else{
			ll ab = y-x;
			ll divi = y/2;
			ll opsdivi = 1LL + abs(divi - x);
			if (opsdivi <= ab){
				return ans = 1LL + f(y/2LL);
			}else{
				return ans = ab + f(x);
			}
		}
	}else if (y<x){
		return ans = x-y + f(x);
	}else return ans = 0LL;
}

void solve(){
	ll y; cin >> x >> y;
	cout << f(y) << '\n';
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int t = 1; //cin >> t;
	while(t--) solve();

	return 0;
}
// NK
