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