#include <assert.h>
#include <stdio.h>

int main() {
  int n, m, ans = -1;

  assert(freopen("prizes.in", "r", stdin));
  assert(freopen("prizes.out", "w", stdout));

  assert(scanf("%d%d", &n, &m) == 2);
  if (n >= 3 && m >= 3)
    ans = 1;
  else if (n >= 2 && m >= 2)
    ans = 0;
  else
    ans = (n + m) / 4;
  printf("%d\n", ans);

  return 0;
}

