#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  if (a > b) swap(a, b);
  int ch = 0;
  int cnt = 0;
  while (a < b) {
    if (ch == 0) {
      a++;
      ch = 1;
    } else {
      b--;
      ch = 0;
    }
    cnt++;
  }
  cout << cnt;
}
