#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1e9 + 7;
const int MAX = 200009;
long long rec(int a, int b) {
  if (a <= 0 || b <= 0) return 0;
  if (a < b and b >= 2 and a >= 1)
    return rec(a - 1, b - 2) + 1;
  else if (a >= 2 and b >= 1)
    return rec(a - 2, b - 1) + 1;
  return 0;
}
int main() {
  int n, m;
  while (cin >> n >> m) {
    cout << rec(n, m) << endl;
  }
  return 0;
}
