#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int brojac = 0;
  while (n > 0 && m > 0) {
    if (n >= m) {
      n -= 2;
      m--;
      if (n >= 0 && m >= 0) brojac++;
    } else {
      n--;
      m -= 2;
      if (n >= 0 && m >= 0) brojac++;
    }
  }
  cout << brojac;
}
