#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int ret = 0;
  for (int a = (0); a < (int)(n + 1); a++) {
    if (2 * a > m) break;
    int b = min(m - 2 * a, (n - a) / 2);
    ret = max(ret, a + b);
  }
  cout << ret << endl;
  return 0;
}
