#include typedef long long int ll; using namespace std; ll N,M; int main(){ ios::sync_with_stdio(false); cin>>N>>M; if (N <= M) cout << 1 << endl; else if (N % 2 == 0 && N <= M * 2) cout << 2 << endl; else cout << -1 << endl; return 0; }