#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    for (int g = b; b > a; g--){
        if(b/g-(a-1)/g >=2){
            cout << g << endl;
            return 0;
        }
    }
}
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int> >
#define ss second
#define ff first
#define ll long long
#define int ll
#define popcount(x) __builtin_popcountll(x)
#define pii pair<int , int>
#define arr array
 
const int mod = 1e9+7;
 
template <typename T>inline T gcd(T a, T b) { while (b != 0) swap(b, a %= b); return a; }
 
vector<string> split(const string& s, char c) {
    vector<string> v; stringstream ss(s); string x;
    while (getline(ss, x, c)) v.push_back(x); return move(v);
}
template<typename T, typename... Args>
inline string arrStr(T arr, int n) {
    stringstream s; s << "[";
    for(int i = 0; i < n - 1; i++) s << arr[i] << ",";
    s << arr[n - 1] << "]";
    return s.str();
}
 
#define EVARS(args...) {__evars_begin(__LINE__); __evars(split(#args, ',').begin(), args);}
 
inline void __evars_begin(int line) { cerr << "#" << line << ": "; }
template<typename T> inline void __evars_out_var(vector<T> val) { cerr << arrStr(val, val.size()); }
template<typename T> inline void __evars_out_var(T* val) { cerr << arrStr(val, 10); }
template<typename T> inline void __evars_out_var(T val) { cerr << val; }
inline void __evars(vector<string>::iterator it) { cerr << endl; }
 
template<typename T, typename... Args>
inline void __evars(vector<string>::iterator it, T a, Args... args) {
    cerr << it->substr((*it)[0] == ' ', it->length()) << "=";
    __evars_out_var(a);
    cerr << "; ";
    __evars(++it, args...);
}

int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1}; //4 Direction
// char dc[] = {'D' , 'R' , 'U' , 'L'};

// int dx[]={1,1,0,-1,-1,-1,0,1};
// int dy[]={0,1,1,1,0,-1,-1,-1};  // 8D
 
void solve(){
    int a , b;
    cin >> a>> b;
    int MAX_gcd = gcd(a , b);
    int flag = 1;
    for (int i = 1 ; i <= b ; i++){
        int n1 = ((a+i-1)/i)*i;
        int n2 = n1 + i;
        if (n1 >= a && n2 >= a && n1 <= b && n2 <= b){
            MAX_gcd = max(MAX_gcd , i);
        }
    }
    cout << MAX_gcd << endl;
}
 
int32_t main(){
 
    // #ifndef ONLINE_JUDGE
    // // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif
 
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1;
    // cin >> t;
    for (int tt = 0 ; tt < t ; tt++){
        // cout << "Case #" << (tt+1) <<": ";
        solve();
    }
}