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

int main(){
  long long A,B;
  cin >> A >> B;
  vector<long long> V(200001,0);
  
  for(long long i=A;i<=B;i++){
    V[1]++;
    V[i]++;
    for(long long j=2;j*j<=i;j++){
      if(i%j==0){
        V[j]++;
        if(i/j!=j) V[i/j]++;
      }
    }
  }
  
  for(int i=200000;;i--){
    if(V[i]>=2){
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	int ans = 1;
	for (int i = 1; i <= b; i++) {
		for (int j = 2; j * j <= i; j++) {
			if (i % j == 0) {
				int k = (a + j - 1) / j * j;
				if (k <= b && k + j <= b) {
					ans = max(ans, j);
				}
			}
			if (i % j == 0) {
				int k = (a + (i / j) - 1) / (i / j) * (i / j);
				if (k <= b && k + i / j <= b) {
					ans = max(ans, (i / j));
				}
			}
		}
	}
	cout << ans << endl;
}