#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void upmax(T &first, T second) {
  first < second ? first = second : 0;
}
template <typename T>
inline void upmin(T &first, T second) {
  first > second ? first = second : 0;
}
const int inf = 0x3f3f3f3f;
const int N = 1e5 + 10;
int main() {
  ios::sync_with_stdio(false);
  long long n, first;
  cin >> n >> first;
  cout << (first * 2 == n ? first * 3 : n * 2 + first) << endl;
  return 0;
}
