#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  if (n > m) swap(n, m);
  int res = 0;
  while (2 * n > m) {
    n -= 2;
    m -= 1;
    res++;
  }
  res += n;
  cout << res;
  return 0;
}
