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