#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  if (n == 0 || m == 0)
    printf("0\n");
  else if (n <= (n + m) / 3 && m >= 2 * (n + m) / 3)
    printf("%d\n", n);
  else if (n > (n + m) / 3 && m >= (n + m) / 3)
    printf("%d\n", (n + m) / 3);
  else if (n >= 2 * m)
    printf("%d\n", m);
}
