#include <bits/stdc++.h>
int main() {
  long long n, m;
  std::cin >> n >> m;
  long long l = 0, r = std::max(n, m) + 1;
  while (r - l != 1) {
    long long mid = l + (r - l) / 2;
    bool can = false;
    for (long long o = mid; o <= 2 * mid; ++o) {
      if (o <= n && 3 * mid - o <= m) {
        can = true;
        break;
      }
    }
    if (can) {
      l = mid;
    } else {
      r = mid;
    }
  }
  std::cout << l;
}
