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