L, K = map(int, input().split()) s, mod = divmod(L, K*2) s = (s-1) if mod == 0 else s print(K * s)