#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, ans;
  cin >> a >> b;
  if ((a - b) % 3 == 0)
    ans = a + b - 3;
  else
    ans = a + b - 2;
  if (ans >= 0)
    cout << ans;
  else
    cout << "0";
  return 0;
}
