L,K = map(int,input().split(" ")) t_cnt = 0 cnt = L // (2 * K) #かじる回数 ans = cnt * K if L <= 2 * K: print(0) elif L % (2 * K) == 0: print(ans - K) else: print(ans)