#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, i, j, s = 0, f;
  bool **tri;
  cin >> n >> x;
  tri = (bool **)malloc(sizeof(bool *) * n);
  for (i = 1; i <= n; i++) tri[i] = (bool *)malloc(sizeof(bool) * i);
  i = x;
  j = 0;
  tri[i][j] = 1;
  while (1) {
    if (i == j) {
      f = 0;
    } else if (j == 0) {
      f = 1;
    } else if (i == n) {
      f = 2;
    }
    switch (f) {
      case 0:
        i++;
        if (tri[i][j] == 1) f = 2;
        break;
      case 1:
        j++;
        if (tri[i][j] == 1) f = 2;
        break;
      case 2:
        i--;
        j--;
        if (tri[i][j] == 1) f = 0;
        break;
      default:
        break;
    }
    s++;
    if (tri[i][j] == 0) {
      tri[i][j] = 1;
    } else if (i == x && j == 0) {
      break;
    }
  }
  for (i = 1; i <= n; i++) free(tri[i]);
  free(tri);
  cout << s << endl;
  return 0;
}
