#include <bits/stdc++.h>
template <typename T>
inline bool in_range(T const &lower, T const &a, T const &upper) {
  return lower < a && a < upper;
}
namespace fst {
using i8 = std::int_fast8_t;
using i16 = std::int_fast16_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u16 = std::uint_fast16_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
}  // namespace fst
namespace lst {
using i8 = std::int_least8_t;
using i16 = std::int_least16_t;
using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u8 = std::uint_least8_t;
using u16 = std::uint_least16_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
}  // namespace lst
using namespace std;
using namespace fst;
using itr = i32;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  i64 N, X;
  cin >> N >> X;
  if (X * 2 >= N)
    cout << X * 3;
  else
    cout << N + 4 * X - 1;
  return 0;
}
