#include using namespace std; int main(void) { int n, m; cin >> n >> m; if (m >= n) { cout << 1 << endl; } else if (n & 1) { cout << -1 << endl; } else { cout << (m >= n / 2 ? 2 : -1) << endl; } return 0; }