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