#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << setprecision(9);
  cout << fixed;
  int n, m;
  cin >> n >> m;
  int count = 0;
  while (n + m > 2 and n > 0 and m > 0) {
    if (n > m) {
      n -= 2;
      m--;
    } else {
      m -= 2;
      n--;
    }
    count++;
  }
  cout << count;
  return 0;
}
