#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int a, b;
  a = max(min(m / 2, n), min(n / 2, m));
  b = (((2 * m - n) / 3) >= 0 && ((2 * n - m) / 3) >= 0) ? (n + m) / 3 : 0;
  cout << max(a, b) << endl;
}
