#include <bits/stdc++.h>
using namespace std;
const int maxn = 10009;
long long n, x;
int main() {
  while (scanf("%lld%lld", &n, &x) != EOF) {
    printf("%lld\n", x + 1 + n + ((n - x) / x) * (2 * x));
  }
  return 0;
}
