#include <bits/stdc++.h>
int min(int a, int b) {
  if (a > b)
    return b;
  else
    return a;
}
int main() {
  int n, m, count = 0;
  scanf("%d%d", &n, &m);
  while (n != 0 && m != 0) {
    if (min(n, m) == n) {
      n--;
      m = m - 2;
    } else if (min(n, m) == m) {
      m--;
      n = n - 2;
    }
    if (n >= 0 && m >= 0) count++;
  }
  printf("%d\n", count);
  return 0;
}
