#include <bits/stdc++.h>
using namespace std;
const long long linf = 1e18 + 5;
int mod = (int)1e9 + 7;
const int logN = 17;
const int inf = 1e9 + 9;
const int N = 2e5 + 5;
int n, m, x, y, z, t, k, q, dp[N], a[N];
int main() {
  long long n, x;
  scanf("%lld %lld", &n, &x);
  printf("%lld\n", (n - x) * 4ll);
  return 0;
}
