#include <bits/stdc++.h>
using namespace std;
void freeopen() {
  freopen(
      ""
      ".in",
      "r", stdin);
  freopen(
      ""
      ".out",
      "w", stdout);
}
const int D = 1e6 + 1;
const int inf = (int)(1u << 31) - 1u;
const long long INF = (long long)(1ull << 63) - 1ull;
const int N = 1e5 + 1;
const int E = 1e3 + 1;
const int edge = 1e9 + 9LL;
const int mod = 1e9 + 7ll;
const int dx[] = {+1, -1, 0, 0};
const int dy[] = {0, 0, +1, -1};
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  int n, m;
  cin >> n >> m;
  int cnt = 0;
  while ((n > 1 && m > 0) || (m > 1 && n > 0)) {
    if (m > n) {
      m -= 2;
      n--;
    } else {
      n -= 2;
      m--;
    }
    cnt++;
  }
  cout << cnt;
  return 0;
}
