#include <bits/stdc++.h>
using namespace std;
long long hcf(long long x, long long y) {
  if (x == 0) return y;
  return hcf(y % x, x);
}
long long lcm(long long a, long long b) { return ((a * b) / hcf(a, b)); }
vector<long long> all_prime(long long n) {
  vector<long long> sieve(n + 1, 0);
  for (long long x = 2; x <= n; x++) {
    if (sieve[x]) continue;
    for (int u = 2 * x; u <= n; u += x) {
      if (sieve[u] == 0) {
        sieve[u] = x;
      }
    }
  }
  return sieve;
}
long long power(long long x, long long n) {
  if (n == 0) return 1;
  long long temp = power(x, n / 2);
  if (n % 2 == 0)
    return temp * temp;
  else
    return x * temp * temp;
}
unsigned long long powerper(unsigned long long x, long long y, long long p) {
  unsigned long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
unsigned long long modInverse(unsigned long long n, long long p) {
  return powerper(n, p - 2, p);
}
unsigned long long nCrModPFermat(unsigned long long n, long long r, long long p,
                                 unsigned long long fac[]) {
  if (n < r) return 0;
  if (r == 0) return 1;
  return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) %
         p;
}
void dfs(vector<vector<long long>> &v, vector<long long> &df, long long seen[],
         long long i) {
  df.push_back(i);
  for (long long j = 0; j < v[i].size(); j++) {
    if (seen[v[i][j]] == 0) {
      seen[v[i][j]] = seen[i];
      dfs(v, df, seen, v[i][j]);
    }
  }
}
void bfs(vector<vector<long long>> &v, long long root, long long seen[]) {
  queue<long long> q;
  seen[root - 1] = 1;
  q.push(root - 1);
  while (!q.empty()) {
    for (long long i = 0; i < v[q.front()].size(); i++) {
      if (seen[v[q.front()][i]] != 1) {
        q.push(v[q.front()][i]);
        seen[v[q.front()][i]] = 1;
      }
    }
    q.pop();
  }
}
long long findConnComp(vector<vector<long long>> &v, long long seen[],
                       long long n) {
  long long j = 0;
  vector<long long> df;
  for (long long i = 0; i < n; i++) seen[i] = 0;
  for (long long i = 0; i < n; i++) {
    if (!seen[i]) {
      seen[i] = ++j;
      dfs(v, df, seen, i);
    }
  }
  return j;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long a, b, ans = 0, diff = 0;
  cin >> a >> b;
  if (a == b) {
    a = a % 3;
    b = b / 3;
    ans += 2 * b;
    if (a == 2) ans++;
  } else if (a < b) {
    diff = b - a;
    if (diff >= a)
      ans += a;
    else {
      a = a - diff;
      b = b - 2 * diff;
      ans += diff;
      a = a % 3;
      b = b / 3;
      ans += 2 * b;
      if (a == 2) ans++;
    }
  } else {
    diff = a - b;
    if (diff >= b)
      ans += b;
    else {
      b = b - diff;
      a = a - 2 * diff;
      ans += diff;
      a = a % 3;
      b = b / 3;
      ans += 2 * b;
      if (a == 2) ans++;
    }
  }
  cout << ans;
}
