#include <bits/stdc++.h>
using namespace std;
struct cww {
  cww() {
    ios::sync_with_stdio(false);
    cin.tie(0);
  }
} star;
template <typename T>
void Scan(T& t) {
  cin >> t;
}
template <typename First, typename... Rest>
void Scan(First& first, Rest&... rest) {
  cin >> first;
  Scan(rest...);
}
inline string zero(int a, string s, char c = '0') {
  return string(a - ((int)(s).size()), c) + s;
}
inline string zero(int a, int t, char c = '0') {
  return zero(a, to_string(t), c);
}
inline string zero(int a, long long t, char c = '0') {
  return zero(a, to_string(t), c);
}
template <class T>
inline void print(T t) {
  cout << t << '\n';
}
template <class H, class... T>
inline void print(H h, T... t) {
  cout << h << " ";
  print(t...);
}
int solve() {
  int n, x;
  Scan(n, x);
  ;
  return 4 * n - 4 * x;
}
int main() {
  print(solve());
  return 0;
}
