#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,m;cin >> n >> m;
  
  if(n <= m) cout << 1 << endl;
  else{
  	if(n % 2 != 0) cout << -1 << endl;
  	else{
  		if(n / 2 <= m) cout << 2 << endl;
  		else cout << -1 << endl;
  	}
  }
  return 0;
}