#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << setprecision(12);
  int n;
  cin >> n;
  ;
  int m;
  cin >> m;
  ;
  int max_teams = 0;
  for (int t1 = 0; t1 <= min(n, m / 2); t1++) {
    int t2 = min((n - t1) / 2, m - 2 * t1);
    max_teams = max(max_teams, t1 + t2);
  }
  cout << max_teams << endl;
}
