#include using namespace std; int main() { int N, K; cin >> N >> K; int ans = -1; if( K <= N ) ans = K - 1; cout << ans << endl; }