#include <bits/stdc++.h>
using namespace std;
int joy(int a, int b, int** ar) {
  int i, j;
  if (a < 1 || b < 1) return 0;
  if (a == 1 && b == 1) return 0;
  if (ar[i][j] != -1) return ar[i][j];
  int smlo = joy(a + 1, b - 2, ar);
  int sml = joy(a - 2, b + 1, ar);
  int cal = 1 + max(sml, smlo);
  ar[i][j] = cal;
  return cal;
}
int main() {
  int a, b, i, j;
  cin >> a >> b;
  int** ar = new int*[a];
  for (i = 0; i < a; i++) {
    ar[i] = new int[b];
    for (j = 0; j < b; j++) ar[i][j] = -1;
  }
  cout << joy(a, b, ar);
  return 0;
}
