#include <bits/stdc++.h>
using namespace std;
using namespace std;
const int INF = 2147483647;
const long long LLINF = 9223372036854775807LL;
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  int n, m;
  cin >> n >> m;
  if (m <= 3 * n)
    cout << 3 * n - m << endl;
  else
    cout << 0 << endl;
  return 0;
}
