#include <bits/stdc++.h>
using namespace std;
int main() {
  long long x, y, s;
  scanf("%I64d %I64d", &x, &y);
  if ((x - y) >= 0 && (x - y) < 2 * x - 1 && x > 0)
    s = 4 * x - 3;
  else if ((y - x) > 0 && (y - x) <= 2 * y && y > 0)
    s = 4 * y - 2;
  else if ((-x - y) > 0 && (-x - y) <= -2 * x && x < 0)
    s = -4 * x - 1;
  else
    s = -4 * y;
  if (x == 1 && y == 0) s = 0;
  printf("%I64d\n", s);
  return 0;
}
