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