#include using namespace std; int main() { int n, k; cin >> n >> k; if (n < k) { cout << "-1\n"; } else { cout << k - 1 << '\n'; } return 0; }