#include <bits/stdc++.h>
using namespace std;
int main() {
  long long m, n, t, ln, lm, ans = -1;
  cin >> n >> m;
  for (long long i = 0; i <= m; i++) {
    t = i;
    ln = n - 2 * i;
    lm = m - i;
    if (ln >= 0) {
      t += min(lm / 2, ln);
      ans = max(ans, t);
    }
  }
  cout << ans << "\n";
  return 0;
}
