#include #include #include #include #include #include #include #include #include using namespace std; int main() { int N, K; cin >> N >> K; int count; if (N % 2 == 1) { if (2*(K-1) >= N) { count = N; } else if(K==1){ count = 2*K; } else { count = 2 * (K - 1); } } else { if (2 * K >= N)count = N / 2; else count = K; } cout << count<