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