#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int x, y, z, m, n, a, b, c, i, j;
  while (cin >> n >> m) {
    x = n;
    y = m;
    j = 0;
    while (1) {
      if (x < 2 && y < 2) break;
      if (x < 1) break;
      if (y < 1) break;
      if (x > y) {
        x = x - 2;
        y = y - 1;
        j++;
      } else {
        y = y - 2;
        x = x - 1;
        j++;
      }
    }
    cout << j << endl;
  }
}
