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