#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, y, c, r;
  cin >> x >> y;
  if ((x == 1 && y == 2) || (y == 1 && x == 2) || (x == 2 && y == 2)) {
    cout << 1;
    return 0;
  }
  if (x <= 2 && y <= 2) {
    cout << 0;
    return 0;
  }
  c = 1;
  for (;;) {
    if (x > 2 && x % 2 == 0) {
      r = (x - 2) / 2;
      x = 2;
      c += r;
      y += r;
    } else if (x > 2 && x % 2 != 0) {
      r = (x - 1) / 2;
      x = 1;
      c += r;
      y += r;
    } else if (y > 2 && y % 2 == 0) {
      r = (y - 2) / 2;
      y = 2;
      c += r;
      x += r;
    } else if (y > 2 && y % 2 != 0) {
      r = (y - 1) / 2;
      y = 1;
      c += r;
      x += r;
    }
    if (x <= 2 && y <= 2) break;
  }
  cout << c;
  return 0;
}
