#include <bits/stdc++.h>
using namespace std;
int n, m, s;
int main() {
  cin >> n >> m;
  while (n > 0 && m > 0) {
    n--;
    m--;
    if (n == 0 && m == 0) break;
    if (n >= m)
      n--;
    else
      m--;
    s++;
  }
  cout << s << endl;
}
