from collections import * from itertools import * from functools import * from heapq import * import sys, math, random, time L, K = map(int, input().split()) ans, flg = divmod(L, 2 * K) if flg: print(ans * K) else: print(max(ans - 1, 0) * K)