import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long low = sc.nextLong(); long high = sc.nextLong(); long maxNumber = high / 2 * 2; for (long i = (long)(Math.sqrt(high)); i >= 3 ; i--) { if (!isPrime(i)) { continue; } for (long j = high / i * i; j >= low; j -= i) { if (getMax(j) >= i) { System.out.println(j); return; } } } System.out.println(maxNumber); } static long getMax(long x) { for (long i = 2; i <= Math.sqrt(x); i++) { if (x % i == 0) { return i; } } return x; } static boolean isPrime(long x) { for (long i = 2; i <= Math.sqrt(x); i++) { if (x % i == 0) { return false; } } return true; } }