#include int main(void) { int a, b, c; scanf("%d%d", &a, &b); if (b == 0 || a < b || a == 0) { c = 0; } else if (a % 2 == 1 && (a + 1) / 2 == b) { c = a - 1; } else { c = a - 2; } printf("%d\n", c); return 0; }