#include <bits/stdc++.h>
using namespace std;
int main() {
  long int n, m, ct = 0, ct1 = 0, p, q;
  cin >> n >> m;
  p = n;
  q = m;
  if (n + m >= 3) {
    while (n > 0 && m > 1) {
      if (m >= n) {
        m -= 2;
        n--;
        ct++;
      } else if (m < n) {
        m -= 1;
        n -= 2;
        ct++;
      }
    }
    if (n > 0 && m > 1) {
      ct++;
      n--;
      m -= 2;
    }
    if (n > 1 && m > 0) {
      ct++;
      m -= 2;
      n -= 1;
    }
    n = p;
    m = q;
    while (n > 1 && m > 0) {
      if (m >= n) {
        m -= 2;
        n--;
        ct1++;
      } else if (m < n) {
        m -= 1;
        n -= 2;
        ct1++;
      }
    }
    if (n > 0 && m > 1) {
      n--;
      m -= 2;
      ct1++;
    }
    if (n > 1 && m > 0) {
      m -= 2;
      n -= 1;
      ct1++;
    }
  }
  cout << ct << "\n";
}
