#include <bits/stdc++.h>
using namespace std;
const int N = 555;
long long n, m, ans;
int main() {
  scanf("%lld %lld", &n, &m);
  while (n > 1 && m > 0 || n > 0 && m > 1) {
    if (n <= m) {
      --n;
      m -= 2;
      ++ans;
    } else {
      --m;
      n -= 2;
      ++ans;
    }
  }
  printf("%lld", ans);
  return 0;
}
