#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const int inf = 1e9;
const int mod = 1e9 + 7;
const double EPS = (double)1e-9;
const double pi = acos(-1.0);
const int MAXN = 1e6 + 5;
long long n, x;
int main() {
  cin >> n >> x;
  cout << (n / x + (long long)(n % x != 0)) * x + (n - x) +
              (n / x + (long long)(n % x != 0)) *
                  (x / 2 + (long long)(x % 2 != 0));
  return 0;
}
