#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, i, j, n, m, x, y, sum = 0, flag;
  cin >> n >> m;
  while (1) {
    if (n == 0 || m == 0) break;
    if (n == 1 && m == 1) break;
    if (n > m)
      n -= 2, m--, sum++;
    else if (n <= m)
      n--, m -= 2, sum++;
  }
  cout << sum;
  return 0;
}
