#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m;
  cin >> n >> m;
  long long ct = 0;
  while ((n >= 2 and m >= 1) or (n >= 1 and m >= 2)) {
    if (n > m and n > 1 and m > 0) {
      n -= 2;
      m -= 1;
      ct++;
    } else if (n <= m and n > 0 and m > 1) {
      m -= 2;
      n -= 1;
      ct++;
    }
  }
  cout << ct;
  return 0;
}
