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