#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, p, pie;
  pie = 0;
  cin >> a >> p;
  p += a * 3;
  for (int i = 0; p > 0; i++) {
    p -= 2;
    pie++;
  }
  cout << pie << endl;
}
