#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-7;
const int inf = 0x3f3f3f3f;
inline long long read() {
  long long f = 1, x = 0;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }
  return f * x;
}
const int mod = 1e9 + 7, N = 1e5 + 10;
int head[N], to[N << 1], nex[N << 1], value[N << 1], cnt;
int sz[N], w[N], n;
void add(int x, int y, int w) {
  to[cnt] = y;
  nex[cnt] = head[x];
  value[cnt] = w;
  head[x] = cnt++;
}
void dfs(int rt, int fa) {
  sz[rt] = 1;
  for (int i = head[rt]; i; i = nex[i]) {
    if (to[i] == fa) continue;
    dfs(to[i], rt);
    w[to[i]] = value[i];
    sz[rt] += sz[to[i]];
  }
}
int main() {
  long long n, x;
  while (scanf("%lld %lld", &n, &x) != EOF) {
    printf("%lld\n", 4 * n - 4 * x);
  }
  return 0;
}
