#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, X, num;
  cin >> N;
  cin >> X;
  if (N % X == 0) {
    num = N / X - 1;
  } else {
    num = N / X;
  }
  cout << num * 3 * X << endl;
}
