#include<bits/stdc++.h>
#define fasterthanlight ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define int long long
#define vi vector<int>
#define pb push_back
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
#define hi "visited\n" //sasta debugging
using namespace std;

//author::@whohet-->Het Patel

int findMaxGCD(int *arr, int n)
{
	// Calculating MAX in array
	int high = 0;
	for (int i = 0; i < n; i++)
		high = max(high, arr[i]);

	// Maintaining count array
	int count[high + 1] = {0};
	for (int i = 0; i < n; i++)
		count[arr[i]]++;

	// Variable to store the
	// multiples of a number
	int counter = 0;

	// Iterating from MAX to 1
	// GCD is always between
	// MAX and 1. The first
	// GCD found will be the
	// highest as we are
	// decrementing the potential
	// GCD
	for (int i = high; i >= 1; i--)
	{
		int j = i;
		counter = 0;

		// Iterating from current
		// potential GCD
		// till it is less than
		// MAX
		while (j <= high)
		{
			// A multiple found

			if (count[j] >= 2)
				return j;

			else if (count[j] == 1)
				counter++;

			// Incrementing potential
			// GCD by itself
			// To check i, 2i, 3i....
			j += i;

			// 2 multiples found,
			// max GCD found
			if (counter == 2)
				return i;
		}
	}
	return 1;
}
void solve()
{
	int a, b;
	cin >> a >> b;
	int n = b - a + 1;
	int arr[n];
	int tmp = a;
	for (int i = 0; i < n; i++)
	{
		arr[i] = tmp; tmp++;
	}
	cout << findMaxGCD(arr, n);
}
signed main()
{
	fasterthanlight;
	int T; T = 1;
	//cin >> T;
	while (T--)
	{
		solve();
	}

	//cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
}
#include<bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define swap(a,b) (a^=b^=a^=b)
#define ll long long int
#define ull unsigned long long int
#define uint unsigned int
#define format(a) memset(a,0,sizeof(a))
#define rep(x,y,z) for(int x=y;x<=z;x++)
#define dec(x,y,z) for(int x=y;x>=z;x--)
#define mst(x) memset(x,0,sizeof(x))
const int maxn=105;
inline int read()
{
    int ans=0;
    char last=' ',ch=getchar();
    while(ch<'0'|ch>'9')last=ch,ch=getchar();
    while(ch>='0' && ch<='9')ans=ans*10+ch-'0',ch=getchar();
    if(last=='-')ans=-ans;
    return ans;
}
int main()
{
    int a,b;
    cin>>a>>b;
    dec(i,b-a,1)
    {
        rep(j,(max(a,i)+i-1)/i*i,b-i)
        {
            if(__gcd(j,j+i)==i)
            {
                cout<<i<<endl;
                return 0;
            }
        }
    }

    return 0;
}
//100001 200000
