#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int cnt = 0;
  if ((n == 1 && m == 1) || (n == 0 || m == 0)) {
    printf("%d", 0);
    return 0;
  }
  while (n + m >= 3) {
    if (n < m) {
      n -= 1;
      m -= 2;
      cnt++;
    } else {
      n -= 2;
      m -= 1;
      cnt++;
    }
    if (n == 0 || m == 0) {
      break;
    }
  }
  printf("%d", cnt);
}
