#include <bits/stdc++.h>
using namespace std;
long long n, m, i, j, c, s, xp, nb;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> xp >> nb;
  while (1) {
    if (xp + nb >= 3 && nb != 0 && xp != 0) {
      if (xp >= nb) {
        xp = xp - 2;
        nb = nb - 1;
      } else {
        xp = xp - 1;
        nb = nb - 2;
      }
    } else
      break;
    c++;
  }
  cout << c;
  return 0;
}
