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