#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200000 + 5;
const int MAX = 1e7;
double pi = 3.1415926535897932384626433832795;
struct Query {
  int x, L, R;
};
int main() {
  long long N, X;
  cin >> N >> X;
  cout << 4LL * (N - X) << endl;
  return 0;
}
