#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int x = 0, y = 0, maxi = 0;
  for (x = 0; x <= 1000000; ++x) {
    y = (n - 2 * x);
    if (y >= 0 && 2 * y + x <= m) {
      maxi = max(maxi, x + y);
    }
  }
  for (y = 0; y <= 1000000; ++y) {
    x = (m - 2 * y);
    if (x >= 0 && 2 * x + y <= n) {
      maxi = max(maxi, x + y);
    }
  }
  cout << maxi;
  return 0;
}
