#include using namespace std; typedef unsigned long long ull; typedef long long ll; int main(){ int n, m; cin >> n >> m; if(n%2==0){ if(m>=n/2) cout << 2 << endl; else cout << -1 << endl; }else{ if(n==m) cout << 1 << endl; else cout << -1 << endl; } return 0; }