#include <bits/stdc++.h>
int main() {
  int a, b, tam, s;
  scanf("%d", &a);
  scanf("%d", &b);
  if (a > b) {
    if ((a - b) % 3 == 1 || (a - b) % 3 == 2 && (a - b) != 0) {
      s = a + b - 2;
    } else
      s = a + b - 3;
  } else {
    if ((b - a) % 3 == 1 || (b - a) % 3 == 2 && (b - a) != 0) {
      s = a + b - 2;
    } else
      s = a + b - 3;
  }
  if (s < 0) s = 0;
  printf("%d", s);
  return 0;
}
