#include <bits/stdc++.h>
using namespace std;
template <typename T>
void in(T &x) {
  x = 0;
  bool neg = false;
  register T c = getchar();
  if (c == '-') neg = true, c = getchar();
  while ((c < 48) || (c > 57)) c = getchar();
  for (; c < 48 || c > 57; c = getchar())
    ;
  for (; c > 47 && c < 58; c = getchar()) x = (x << 3) + (x << 1) + (c & 15);
  if (neg) x *= -1;
}
template <typename T>
void out(T n) {
  bool neg = 0;
  if (n < 0) n *= -1, neg = 1;
  char snum[65];
  int i = 0;
  do {
    snum[i++] = n % 10 + '0';
    n /= 10;
  } while (n);
  --i;
  if (neg) putchar('-');
  while (i >= 0) putchar(snum[i--]);
}
template <typename T>
void outln(T n) {
  bool neg = 0;
  if (n < 0) n *= -1, neg = 1;
  char snum[65];
  int i = 0;
  do {
    snum[i++] = n % 10 + '0';
    n /= 10;
  } while (n);
  --i;
  if (neg) putchar('-');
  while (i >= 0) putchar(snum[i--]);
  putchar('\n');
}
vector<long long> vll;
int main() {
  long long a, b;
  in(a);
  in(b);
  long long n = ceil((a - b) / b + .5);
  out(n * 3 * b);
}
