#include <bits/stdc++.h>
using namespace std;
int main() {
  int ans = 0, a, b, a2, b2;
  cin >> a >> b;
  while (((a != 0) and (b != 0))) {
    if ((a + b) <= 2) {
      cout << ans << endl;
      return 0;
    }
    if (2 * a <= b) {
      cout << ans + a << endl;
      return 0;
    }
    if (2 * b <= a) {
      cout << ans + b << endl;
      return 0;
    }
    if (a == 2 and b == 2) {
      cout << ans + 1 << endl;
      return 0;
    }
    int aux = a;
    int aux2 = b;
    a = min(aux, aux2);
    b = max(aux, aux2);
    while (a < b) {
      a--;
      b -= 2;
      ans++;
    }
    aux = a / 3;
    a = a - aux * 3;
    b = b - aux * 3;
    aux = aux * 2;
    ans += aux;
  }
  cout << ans << endl;
  return 0;
}
