	#include "bits/stdc++.h"
	using namespace std;
	#define mod 1000000007
	#define pie  3.14159265
	#define ll long long int
	#define fr(i,a,n) for(ll i=a;i<n;i++)
	#define vi vector<int>
	#define vlli vector<ll>
	#define pb push_back
	#define ppb pop_back
	#define mp make_pair
	#define fv(i,a) for(auto i:a)
	#define sz(a) int((a).size())
	#define all(c) (c).begin(),(c).end()
	#define frv(i,c) for(auto i = c.begin(); i != c.end(); i++)

	void solve()
	{
		ll a, b;
		cin >> a >> b;
		ll m = -1;
		fr(i, 1, b)
		{
			ll x = (a - 1) / i;
			ll y = b / i;
			if (y - x >= 2)
				m = max(m, i);

		}
		cout << m << endl;
	}


	int main() {
	//#ifndef ONLINE_JUDGE
	#ifdef yogi23
		freopen("input.txt", "r", stdin);
		freopen ("output.txt", "w", stdout);
	#endif
		ios_base::sync_with_stdio(false);
		cin.tie(NULL);
		int t;
		t = 1;
		//cin >> t;
		while (t--)
		{
			solve();
		}


		return 0;
	}
#include <iostream>
#include <cmath>
using namespace std;
int getMaxGCD(int arr[], int n) {
   int high = 0;
   for (int i = 0; i < n; i++)
   high = max(high, arr[i]);
   int divisors[high + 1] = { 0 }; //array to store all gcd values
   for (int i = 0; i < n; i++) {
      for (int j = 1; j <= sqrt(arr[i]); j++) {
         if (arr[i] % j == 0) {
            divisors[j]++;
         if (j != arr[i] / j)
            divisors[arr[i] / j]++;
         }
      }
   }
   for (int i = high; i >= 1; i--)
   if (divisors[i] > 1)
   return i;
}
int main() {
    int a,b;
    cin >> a >> b;
    int arr[b-a+1];
    int t=0;

    for(int i=a;i<=b;i++){
        arr[t] = i;
        t++;
    }

    int n = sizeof(arr) / sizeof(arr[0]);
    cout << getMaxGCD(arr,n);

}