#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  long long a, b;
  cin >> a >> b;
  if (a > b) swap(a, b);
  if (max(a, b) <= 1) {
    cout << "0";
    return 0;
  }
  if ((b - a) % 3 == 0) {
    cout << (b - a) / 3 + ((a + (b - a) / 3 - 1) * 2 - 1) << endl;
    return 0;
  }
  cout << (b - a) / 3 + (b - (b - a) / 3 * 2 - 1) * 2 - (b - a) % 3 << endl;
  return 0;
}
