#include <bits/stdc++.h>
using namespace std;
int arr[10005];
int main() {
  int n, m, sum = 0;
  cin >> n >> m;
  int d = n - m;
  if (d < 0) d -= 2 * d;
  d = d / 2;
  if (d == 1 | d == 0) {
    cout << "1" << endl;
  } else if (d % 2 == 0) {
    cout << d * 2 << endl;
  } else
    cout << 2 * d - 1 << endl;
}
