#include <bits/stdc++.h>
using namespace std;
const int e = 1e6;
long long a[e], b[e], c[e];
long long m, n, dem = 0;
long long minn = 1e18;
long long mini;
int main() {
  fill_n(c, e, 0);
  cin >> n >> m;
  if (n == 1 && m == 1) {
    cout << 0;
  } else {
    while (n > 0 && m > 0) {
      if (m >= n) {
        m -= 2;
        n += 1;
      } else if (n > m) {
        n -= 2;
        m++;
      }
      dem++;
    }
    cout << dem;
  }
}
