#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e4;
const int inf = 1 << 30;
long long k, n;
int main() {
  cin >> n >> k;
  long long ans = 4 * (n - k);
  cout << ans << endl;
  return 0;
}
