#include #define rep(X,N) for(ll X = 0; X < (N); X++) #define PI (acos(-1.0)) #define pback push_back #define mpair make_pair #define MODN 1000000007 #define ALL(V) (V).begin(),(V).end() #define CERR if(false) cerr #define INT_MAX_HALF (INT_MAX / 2) #define EPS (1e-10) using namespace std; typedef long long ll; int main(){ int n,k; cin >> n >> k; int ans = k - 1; if(k > n) ans = -1; cout << ans << endl; return 0; }