#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n, m, counter = 0;
  cin >> n >> m;
  while (n > 0 && m > 0) {
    if (n < m) {
      if (n >= 1 && m >= 2) {
        --n;
        m -= 2;
        ++counter;
      } else {
        break;
      }
    } else {
      if (n >= 2 && m >= 1) {
        n -= 2;
        --m;
        ++counter;
      } else {
        break;
      }
    }
  }
  cout << counter;
  return 0;
}
