#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, P;
  cin >> A >> P;
  int piece = A / 3;
  int allPiece = piece + P;
  if ((allPiece / 2) <= 0) {
    cout << 0 << endl;
  } else {
    cout << allPiece / 2 << endl;
  }
}
