#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, ans;
  cin >> a >> b;
  if (a > b) swap(a, b);
  if (a + b < 3 || a == 0)
    ans = 0;
  else if (a * 2 <= b)
    ans = a;
  else {
    int t = a;
    while (a * 2 > b && a > 0) {
      a--;
      b++;
    }
    if (a == 0)
      ans = t;
    else
      ans = a;
  }
  cout << ans << endl;
}
