#include <bits/stdc++.h>
using namespace std;
bool cmp(pair<int, int> p1, pair<int, int> p2) {
  if (p1.first != p2.first) return p1 > p2;
  return p1 < p2;
}
long long int binpow(long long int a, long long int b) {
  long long int res = 1;
  while (b > 0) {
    if (b % 2 == 0) res = res * a;
    a *= a;
    b /= 2;
  }
  return res;
}
long long int fact(long long int n) {
  if (n == 1 || n == 0)
    return 1;
  else
    return n * fact(n - 1);
}
long long int ncr(long long int n, long long int r) {
  long long int a = fact(n);
  long long int b = fact(r);
  long long int c = fact(n - r);
  return a / (b * c);
}
string dectobin(long long int n) {
  string s = bitset<32>(n).to_string();
  return s;
}
void solve() {
  long long int n;
  long long int m;
  cin >> n;
  cin >> m;
  long long int cur = 0, ans = 0;
  for (long long int i = 0; i <= n; i++) {
    cur = i;
    long long int nleft = n - i;
    long long int mleft = m - 2 * i;
    if (mleft >= 0) {
      cur += min(mleft, nleft / 2);
      ans = max(ans, cur);
    }
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int T = 1;
  while (T--) solve();
  return 0;
}
