#include <bits/stdc++.h>
using namespace std;
long long n, ans;
string str;
long long solve() {
  long long k;
  cin >> n >> k;
  long long t = 3 * n;
  while (t > k) {
    t--;
    ans++;
  }
  cout << ans;
  return 0;
}
signed main() {
  ios::sync_with_stdio(0);
  long long t = 1;
  while (t--) solve();
  return 0;
}
