L,K = map(int, raw_input().split()) for i in range(0,L/K): L = L - 2 * K if L <= 0: print i * K break