#include #include #include using namespace std; int main(){ long long N, K; cin >> N >> K; if(N % 2 == 0){ if(N > K * 2){ cout << (K * 2 + 1) / 2 + 1 << endl; return 0; } else{ cout << N / 2 << endl; return 0; } } else{ if(N > K){ cout << (K * 2 + 1) / 2 + 1 << endl; return 0; } else{ cout << N << endl; } } }