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