#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int MAX = 1e6;
int main() {
  int t = 1;
  while (t--) {
    long long n, m;
    cin >> n >> m;
    if (n == 0 || m == 0) {
      cout << 0;
      return 0;
    }
    if (n == 1 && m == 1) {
      cout << 0;
      return 0;
    }
    if (n > m) swap(n, m);
    long long c = 0;
    long long i, j, k;
    while (2 * n > m) {
      n -= 2;
      m -= 1;
      ++c;
    }
    c += n;
    cout << c;
  }
  return 0;
}
