#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n, m, i, ans = 0;
  cin >> n >> m;
  while (n > 0 and m > 0) {
    if (n == 1 and m == 1) break;
    ans++;
    if (n < m) {
      n--;
      m -= 2;
    } else {
      m--;
      n -= 2;
    }
  }
  cout << ans << endl;
  return 0;
}
