#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const long long infl = 2e18;
const int infi = 2e9;
const int mod = 1e9 + 7;
mt19937 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
auto clk = clock();
int rng(int lim) {
  uniform_int_distribution<int> uid(0, lim - 1);
  return uid(rang);
}
template <class t1, class t2, class t3>
t1 fast_expo(t2 x, t3 p) {
  if (p == 0) return 1;
  t1 r = fast_expo(x, p / 2);
  if (p % 2 != 0) return r * r * x;
  return r * r;
}
void solve() {
  long long n, x;
  cin >> n >> x;
  cout << 4 * (n - x);
}
signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  srand(chrono::high_resolution_clock::now().time_since_epoch().count());
  cout << fixed << setprecision(10);
  int t = 1;
  while (t--) solve();
  return 0;
}
