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