#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b;
  cin >> a >> b;
  int result = 0;
  while (1) {
    if (a > b) {
      a -= 2;
      b -= 1;
      if (a < 0 || b < 0) break;
      result++;
    } else {
      b -= 2;
      a -= 1;
      if (a < 0 || b < 0) break;
      result++;
    }
  }
  cout << result << endl;
}
