#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
using ll = long long;
using lli = long long int;
using ld = long double;
using pa = pair<int, int>;
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
ll mod = 1000000007;
void solve() {
  ll n, x;
  cin >> n >> x;
  cout << 4 * n - 4 * x << endl;
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  solve();
  return 0;
}
