#include <bits/stdc++.h>
using namespace std;
long long pwr(long long a, long long b, long long mod) {
  a %= mod;
  if (a < 0) a += mod;
  long long ans = 1;
  while (b) {
    if (b & 1) ans = (ans * a) % mod;
    a = (a * a) % mod;
    b /= 2;
  }
  return ans;
}
long long pwr(long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans *= a;
    a *= a;
    b /= 2;
  }
  return ans;
}
long long gcd(long long a, long long b) {
  while (b) {
    long long temp = a;
    a = b;
    b = temp % b;
  }
  return a;
}
long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }
long long modularInverse(long long a, long long m) {
  assert(false);
  return pwr(a, m - 2, m);
}
int main(int argc, char const *argv[]) {
  std::ios::sync_with_stdio(false);
  int n, m, num1, num2;
  cin >> n >> m;
  if (n > m) {
    num1 = n;
    num2 = m;
  } else {
    num1 = m;
    num2 = n;
  }
  long long sum = 0;
  while (num2 != 0 && num1 >= 2) {
    sum++;
    num2--;
    num1 = num1 - 2;
    if (num1 < num2) {
      swap(num1, num2);
    }
  }
  cout << sum << endl;
  return 0;
}
