l,k = map(int,input().split()) if l%k == 0 and (l/k)%2 == 0: print((l/k/2-1)*k) elif l%k == 0 and (l/k)%2 == 1: print((l/k//2)*k) elif l%k != 0 and (l//k)%2 == 0: print((l//k/2)*k) else: print((l//k//2)*k)