#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
struct aaa {
  aaa() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
} aaaaaaa;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
const double pi = acos(-1.0);
const long long inf = 1LL << 60;
bool isPrime(long long n) {
  if (n < 2) return false;
  for (long long x = 2; x * x <= n; x++) {
    if (n % x == 0) return false;
  }
  return true;
}
long long kaizyo(long long k) {
  long long sum = 1;
  for (int i = 1; i <= k; i++) {
    sum *= i;
    sum %= mod;
  }
  return sum;
}
long long ncr(long long n, long long r) {
  return kaizyo(n) / (kaizyo(r) * kaizyo(n - r));
}
unsigned keta(unsigned num) { return log10(num) + 1; }
int main() {
  long long a, b;
  cin >> a >> b;
  ;
  cout << ceil((double)(a - b) / b) * 3 * b;
}
