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