#include using namespace std; int main( int argc, char *argv[] ) {int a,b,c; c=1; cin>>a>>b; while(c<=10^18&&!((c==a&&c==b)&&((c+a)%b==0&&(c+b)%a==0&&(a+b)%c==0))) {c++;} if(c==10^18+1){cout<<-1<