#include using namespace std; int main() { int N, K; cin >> N >> K; auto is_good = [&](int x) -> bool { for (int d = 1; d * d <= x; d++) { if (x%d) continue; if (d <= K and x / d <= K) return false; } return true; }; for (int x = N; x >= max(1, N - 281); x--) { if (is_good(x)) { cout << x << endl; return 0; } } cout << -1 << endl; }