#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int len = min(n / 2, m);
  int ans = 0;
  for (int i = 0; i <= len; i++) {
    int ans1 = min(n - 2 * i, (m - i) / 2);
    if (i + ans1 > ans) ans = i + ans1;
  }
  cout << ans << endl;
}
