#include <bits/stdc++.h>
using namespace std;
long long n, m, a, b, c, d, p, q, r, k;
vector<long long> v, u;
long long zero = 0, one = 0, two = 0;
string s;
void input() { cin >> n >> m; }
long long solve() {
  long long ans = 0;
  while (m + n >= 3 && m >= 1 && n >= 1) {
    if (m > n) {
      ans++;
      m -= 2;
      n--;
    } else {
      m--;
      n -= 2;
      ans++;
    }
  }
  return ans;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long T = 1;
  while (T--) {
    input();
    long long ans = solve();
    cout << ans;
  }
}
