#include <bits/stdc++.h>
int main() {
  int n, m;
  std::cin >> n >> m;
  int ans = 0;
  for (int first = 0; first <= n; ++first) {
    int second = std::min((n - first) / 2, m - 2 * first);
    if (second >= 0) {
      ans = std::max(ans, first + second);
    }
  }
  std::cout << ans << std::endl;
  return 0;
}
