#include <bits/stdc++.h>
const int INF = 200000000;
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  if (n + m < 3) {
    cout << 0;
    return 0;
  }
  int cnt = 0;
  while (n > 0 && m > 0 && n + m >= 3) {
    if (n > m) {
      n -= 2;
      m--;
      cnt++;
      continue;
    } else {
      n--;
      m -= 2;
      cnt++;
      continue;
    }
  }
  cout << cnt;
  return 0;
}
