#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  vector<ll> b;
  ll n, m, i, j, sum = 0, x, y, t, cst, k;
  cin >> n >> m;
  if (n + m < 3 || n == 0 || m == 0) {
    cout << 0 << endl;
    return 0;
  }
  for (i = 0; i >= 0; i++) {
    if (n >= m && n >= 2) {
      n = n - 2;
      m = m - 1;
      sum++;
    } else if (m >= n && m >= 2) {
      m = m - 2;
      n = n - 1;
      sum++;
    }
    if (n <= 0 || m <= 0 || (n == 1 && m == 1)) break;
  }
  cout << sum << endl;
}
