#include <bits/stdc++.h>
using namespace std;
int myPow(int x, int p) {
  if (p == 0) return 1;
  if (p == 1) return x;
  return x * myPow(x, p - 1);
}
int main(int argc, char* argv[]) {
  int n, m, teams = 0;
  cin >> n >> m;
  while (n != 0 && m != 0 && !(n == 1 && m == 1)) {
    if (n >= m) {
      n -= 2;
      m--;
      teams++;
    } else {
      m -= 2;
      n--;
      teams++;
    }
  }
  cout << teams << endl;
}
