#include <bits/stdc++.h>
int main() {
  long long n, m, x, equip = 0;
  scanf("%I64d%I64d", &n, &m);
  while (m > n and n > 0) {
    n--;
    m -= 2;
    equip++;
  }
  while (n > m and m > 0) {
    m--;
    n -= 2;
    equip++;
  }
  if (n == m) equip += (n + m) / 3;
  printf("%d", equip);
  return 0;
}
