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