#include <bits/stdc++.h>
using namespace std;
int cmp(int a, int b) {
  int temp = 0;
  while (a / b != 2) {
    a -= 1;
    b -= 2;
    temp++;
  }
  temp += b;
  cout << temp << endl;
  return 0;
}
int main() {
  int n, m;
  cin >> n >> m;
  if ((n + m) < 3 || m * n == 0) {
    cout << 0 << endl;
    return 0;
  }
  while ((n + m) % 3 != 0) {
    if (n > m) {
      n--;
    } else {
      m--;
    }
  }
  if (m / n >= 2) {
    cout << n << endl;
    return 0;
  } else if (n / m >= 2) {
    cout << m << endl;
    return 0;
  }
  if (n <= m) {
    cmp(n, m);
  }
  if (m < n) {
    cmp(m, n);
  }
  return 0;
}
