#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
int n, m;
int main() {
  int i, j;
  while (~scanf("%d %d", &n, &m)) {
    int ans = 0;
    while (n > 0 && m > 0) {
      if (n < m && n >= 1 && m >= 2) {
        ans++;
        n--;
        m -= 2;
      } else if (n >= m && n >= 2 && m >= 1) {
        ans++;
        n -= 2;
        m--;
      } else
        break;
    }
    printf("%d\n", ans);
  }
  return 0;
}
