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