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