#include <bits/stdc++.h>
int main() {
  int n, k, cant;
  int c = 0;
  double suma, pa, pd;
  scanf("%d%d", &n, &k);
  if ((double)k / n == 2) {
    cant = n;
  } else if ((double)k / n >= 3) {
    cant = 0;
  } else {
    pd = (double)k / n;
    pa = 2;
    suma = 2 * n;
    while (pa < pd) {
      suma = suma + 20;
      pa = (double)suma / n;
      c = c + 20;
    }
    while (pa > pd) {
      suma = suma - 1;
      pa = (double)suma / n;
      c = c - 1;
    }
    cant = n - c;
  }
  printf("%d", cant);
  return 0;
}
