#include <bits/stdc++.h>
using namespace std;
int case1(int n, int m) {
  int y = 2 * n - m;
  if (y < 0) y = 0;
  while (y % 3 != 0) ++y;
  y /= 3;
  int x = n - 2 * y;
  if (x + 2 * y <= n && 2 * x + y <= m && x >= 0 && y >= 0)
    return x + y;
  else
    return 0;
}
int case2(int n, int m) {
  int y = 2 * n - m - 2;
  if (y < 0) y = 0;
  while (y % 3 != 0) ++y;
  y /= 3;
  int x = n - 1 - 2 * y;
  if (x + 2 * y <= n && 2 * x + y <= m && x >= 0 && y >= 0)
    return x + y;
  else
    return 0;
}
int main() {
  int n, m;
  cin >> n >> m;
  int max1 = case1(n, m);
  int max2 = case2(n, m);
  int max11 = case1(m, n);
  int max21 = case2(m, n);
  int maxx = max(max(max1, max2), max(max11, max21));
  cout << maxx << "\n";
  return 0;
}
