#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int A, B;
  cin >> A >> B;
  int ans = 0;
  for (int i = 0; i <= A; i++) {
    int tA = A - i, tB = B - 2 * i;
    if (tB < 0) continue;
    ans = max(ans, i + min(tA / 2, tB));
  }
  cout << ans << endl;
  return 0;
}
