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