#include <bits/stdc++.h>
using namespace std;
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
}
void solve() {
  int n, m, ans = 0;
  cin >> n >> m;
  for (int i = 0; i <= n; i++) {
    int cur = i;
    int leftn = n - i;
    int leftm = m - 2 * i;
    if (leftm >= 0) {
      cur += min(leftm, leftn / 2);
      ans = max(cur, ans);
    }
  }
  cout << ans << '\n';
}
int main() {
  fast();
  solve();
  return 0;
}
