#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;

int main() {
  int n, m; cin >> n >> m;
  if (n <= m) cout << 1 << endl;
  else {
    if (n % 2) cout << -1 << endl;
    else {
      if (n / 2 <= m) cout << 2 << endl;
      else cout << -1 << endl;
    }
  }
  return 0;
}