#include <bits/stdc++.h>
int main() {
  unsigned long long n, x, i, res = 0;
  scanf("%lld %lld", &n, &x);
  unsigned long long tmp = n / x;
  if (n % x == 0) {
    tmp--;
  }
  res += (x * 3) * tmp;
  printf("%lld\n", res);
  return 0;
}
