#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long b, long long m) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = (ans * a) % m;
    b /= 2;
    a = (a * a) % m;
  }
  return ans;
}
int main() {
  long long t = 1, b = 1;
  while (t--) {
    long long n, m;
    cin >> n >> m;
    long long c = 0;
    while (1) {
      if (n <= 0 || m <= 0 || (n == 1 && m == 1)) break;
      if (n <= m) {
        n = n - 1;
        m = m - 2;
        c++;
      } else {
        n = n - 2;
        m = m - 1;
        c++;
      }
    }
    cout << c << "\n";
  }
  return 0;
}
