#include <bits/stdc++.h>
using namespace std;
long long n, m, i, j, k, x=1e18;
int main(){
scanf("%lld%lld", &n, &m);
for(i=sqrt(m)+5; i>=1; i--){
j = (m+i-1) / i;//向上取整
if(i>n || j>n || j<1) continue;
k = x = min(x, i*j);//i、j符合条件,取i*j最小值
}//枚举小的约数i,贪心求大的约数j
if(!k) x = -1;
printf("%lld\n", x);
return 0;
}