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