#include <bits/stdc++.h>
int triangle[1010][1010];
int main(void) {
  int i, N, X, b, c, len, dire_flag;
  scanf("%d%d", &N, &X);
  for (i = 0; i <= N; i++) {
    triangle[0][i] = 3;
    triangle[i][0] = 2;
    triangle[N - i][i] = 1;
  }
  dire_flag = 1;
  b = X - 1;
  c = 1;
  len = 1;
  while (!(b == X && c == 0)) {
    switch (dire_flag) {
      case 1:
        if (triangle[b][c] == 3) {
          dire_flag = 2;
          b++;
        } else if (triangle[b][c] == 2) {
          dire_flag = 3;
          c--;
        } else {
          triangle[b][c] = 1;
          b--;
          c++;
        }
        break;
      case 2:
        if (triangle[b][c] == 1) {
          dire_flag = 3;
          c--;
        } else if (triangle[b][c] == 3) {
          dire_flag = 1;
          b--;
          c++;
        } else {
          triangle[b][c] = 2;
          b++;
        }
        break;
      case 3:
        if (triangle[b][c] == 2) {
          dire_flag = 1;
          b--;
          c++;
        } else if (triangle[b][c] == 1) {
          dire_flag = 2;
          b++;
        } else {
          triangle[b][c] = 3;
          c--;
        }
        break;
    }
    len++;
  }
  printf("%d\n", len);
  return 0;
}
