#include #include int main() { int n, k; scanf("%d%d", &n, &k); printf("%d\n", std::min(k + 1, (n & 1) ? n : n / 2)); return 0; }