#include <bits/stdc++.h>
using namespace std;
int main() {
  long long x, y, m, l, r;
  cin >> x >> y;
  r = max(x, y);
  l = 0;
  while (r != l) {
    m = (l + r) / 2;
    if (m <= min(x, y) and 3 * m <= x + y)
      l = m + 1;
    else
      r = m;
  }
  if (x == 0 and y == 0)
    cout << "0";
  else
    cout << l - 1;
  return 0;
}
