#include <bits/stdc++.h>
using namespace std;
typedef unsigned int UI;
typedef long int LI;
typedef unsigned long int ULI;
typedef long long int LL;
typedef unsigned long long int ULL;
LL mod = 1e9 + 7;
inline int scanInt() {
  int n = 0;
  char ch = getchar();
  int sign = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') sign = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    n = (n << 1) + (n << 3) + (int)(ch - '0');
    ch = getchar();
  }
  return n * sign;
}
inline LL scanLong() {
  LL n = 0;
  char ch = getchar();
  LL sign = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') sign = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    n = (n << 1) + (n << 3) + (LL)(ch - '0');
    ch = getchar();
  }
  return n * sign;
}
int main() {
  LL a = scanLong();
  ;
  LL b = scanLong();
  ;
  LL m = a + b;
  LL time[m + 1][m + 1];
  for (__typeof(m + 1) s = (0) - ((0) > (m + 1));
       s != (m + 1) - ((0) > (m + 1)); s += 1 - 2 * ((0) > (m + 1))) {
    for (__typeof(s + 1) i = (0) - ((0) > (s + 1));
         i != (s + 1) - ((0) > (s + 1)); i += 1 - 2 * ((0) > (s + 1))) {
      LL j = s - i;
      if (i == 0 || j == 0)
        time[i][j] = 0;
      else if (i == 1 && j == 1)
        time[i][j] = 0;
      else if (i == 1)
        time[i][j] = time[i + 1][j - 2] + 1;
      else if (j == 1)
        time[i][j] = time[i - 2][j + 1] + 1;
      else
        time[i][j] = max(time[i - 2][j + 1], time[i + 1][j - 2]) + 1;
    }
  }
  cout << time[a][b] << endl;
}
