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