#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, q;
  cin >> n >> q;
  long long cnt = 0;
  while (max(n, q) >= 2 and n != 0 and q != 0) {
    if (n <= q) {
      n++;
      q -= 2;
      cnt++;
    } else {
      cnt++;
      n -= 2;
      q++;
    }
  }
  cout << cnt;
}
