#include <bits/stdc++.h>
using namespace std;
void splitstr(const string &s, vector<string> &v) {
  istringstream in(s);
  copy(istream_iterator<string>(in), istream_iterator<string>(),
       back_inserter(v));
}
void err(vector<string>::iterator it) {}
template <typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
  cerr << *it << " = " << a << '\n';
  err(++it, args...);
}
const int maxn = 100005;
const long long INF = (1e9) + 7;
const long double EPS = 1e-8;
int main() {
  ios_base::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  int ans = 0;
  while (n > 0 && m > 0) {
    if (n + m > 2)
      if (n > m) {
        n -= 2;
        m--;
        ans++;
      } else {
        m -= 2;
        n--;
        ans++;
      }
    else
      break;
  }
  cout << ans;
  return 0;
}
