#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  int ans = -1e9;
  for (int i = 0; i <= n; i++) {
    int cur = i;
    int cnt1 = n - i;
    int cnt2 = m - 2 * i;
    if (cnt2 >= 0) {
      cur += min(cnt1 / 2, cnt2);
      ans = max(ans, cur);
    }
  }
  cout << ans;
  return 0;
}
