#include <bits/stdc++.h>
const double eps = 1e-9;
const double pi = acos(-1);
using namespace std;
struct sx {};
bool cmp(int a, int b) { return a > b; }
long long t1, t2, t3;
int main() {
  int n, m;
  cin >> n >> m;
  int x = (n + m) / 3;
  while (t1 < x && ((n >= 1 && m >= 2) || (n >= 2 && m >= 1))) {
    if (n > m) {
      n -= 2;
      m -= 1;
    } else {
      m -= 2;
      n -= 1;
    }
    t1++;
  }
  cout << t1;
}
