#include<stdio.h> int main() { int p, d; scanf("%d%d", &d, &p); if (p == 3) printf("%d", d - 1); else printf("%d", d - (p / 2 + 1)); return 0; }