#include using namespace std; int main() { int N, M; cin >> N >> M; cout << (N - 1) / (M * 2) * M << "\n"; }