#include <bits/stdc++.h>
using namespace std;
const long long A = 100000000000000LL, N = 10000;
long long _o, _n, _m, o, i, j, n, m;
int main() {
  cin >> _n >> _m;
  n = _n, m = _m, o = 0;
  while (1) {
    _o = max(_o, o + min(n, m / 2));
    n -= 2, m--, o++;
    if (n < 0 || m < 0) {
      o--;
      break;
    }
  }
  _o = max(o, _o);
  n = _n, m = _m, o = 0;
  while (1) {
    _o = max(_o, o + min(n / 2, m));
    n--, m -= 2, o++;
    if (n < 0 || m < 0) {
      o--;
      break;
    }
  }
  _o = max(o, _o);
  cout << _o;
}
