#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  if (3 * n <= k)
    cout << 0 << endl;
  else
    cout << 3 * n - k << endl;
  return 0;
}
