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