#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, e;
  cin >> e >> n;
  int mxt = 0;
  for (int ta = 0; ta <= (e + n) / 3; ++ta)
    if (e >= ta && n >= 2 * ta) {
      int ee = e, nn = n;
      ee -= ta;
      nn -= 2 * ta;
      ee /= 2;
      int tb = min(ee, nn);
      mxt = max(mxt, ta + tb);
    }
  cout << mxt << endl;
  return 0;
}
