import sys L,K = list(map(int,input().split())) if L <= 2 * K: print(0) exit() q = L // (2*K) r = L % (2 * K) if r == 0: q -= 1 print(q * K)