#include <bits/stdc++.h>
const int MAXN = 1e6;
const int inf = 1e9 + 69;
using namespace std;
int main() {
  int n, m, cnt = 0;
  cin >> n >> m;
  while (true) {
    if (n <= m and n > 0 and m > 1)
      cnt++, n--, m -= 2;
    else if (n > m and n > 1 and m > 0)
      cnt++, n -= 2, m--;
    else
      break;
  }
  cout << cnt;
  return 0;
}
