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