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