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