#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, ans = 0;
  cin >> n >> m;
  while (1) {
    if (n == 0 || m == 0) break;
    if (n == 1 && m == 1) break;
    if (n == m) {
      n -= 2;
      m--;
    } else if (n > m) {
      n -= 2;
      m--;
    } else {
      m -= 2;
      n--;
    }
    ans++;
  }
  cout << ans;
  return 0;
}
