#include <bits/stdc++.h>
using namespace std;
int n, m, ans;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i <= min(n, m / 2); ++i) {
    int tn = n - i, tm = m - i * 2;
    int j = min(tn / 2, tm);
    ans = max(ans, i + j);
  }
  printf("%d\n", ans);
  return 0;
}
