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

int a,b;
unordered_map<int,int> mp;

int main(){

    cin>>a>>b;

    for(int i=a;i<=b;i++){
        for(int j=1;j*j<=i;j++){
            if(i%j==0){
                mp[j]++;
                mp[i/j]++;
            }
        }
    }

    int m = (b-a)+1;
    while(m--){
        if(mp[m]>=2){
            cout<<m<<endl;
            return 0;
        }
    }


    return 0;
}

#include <iostream>
#include <algorithm>

bool check(int p, int a, int b)
{
	int under = (a - 1) / p;
	int top = b / p;
	if (top - under >= 2) 
		return (true);
	return (false);
}

int main(void)
{
	int a, b;
	int ans = 0;
	std::cin >> a >> b;
	for (int p = 1; p <= b; p++)
	{
		if (check(p, a, b))
			ans = std::max(ans, p);
	}
	std::cout << ans << std::endl;
	return (0);
}