#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll inf = 1e18;
using vb = vector<bool>;
using vc = vector<char>;
using vd = vector<double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pi = pair<int, int>;
using pll = pair<ll, ll>;
int a[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
int b[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
ll mod = 1e9 + 7;
inline ll power(ll x, ll y) {
  ll temp;
  if (y == 0) return 1;
  temp = power(x, y / 2);
  if (y % 2 == 0)
    return (temp * temp) % mod;
  else
    return (((x * temp) % mod) * temp) % mod;
}
ll x(ll a, ll b) {
  ll ans = 0;
  for (ll i = 1; i <= a; i++) {
    ll q = a;
    ll p = 0;
    if (2 * i <= b) {
      p += i;
      q -= p;
      ll c = b - (2 * i);
      ll w = min(c, q / 2);
      p += w;
      ans = max(ans, p);
    }
  }
  return ans;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll a, b;
  cin >> a >> b;
  ll ans = x(a, b);
  ll q = x(b, a);
  ans = max(ans, q);
  cout << ans << "\n";
}
