#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, i, ans;
  scanf("%d%d", &a, &b);
  ans = 0;
  while (a > 0 && b > 0 && a + b >= 3) {
    if (a > b) {
      a -= 2;
      b -= 1;
      ans++;
    } else {
      a -= 1;
      b -= 2;
      ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}
