#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
long long N, X;
int main() {
  cin >> N >> X;
  if (2 * X == N)
    cout << 3 * X << endl;
  else
    cout << 2 * N + X << endl;
  return 0;
}
