L,K = map(int,input().split(" ")) t_cnt = 0 cnt = L // (2 * K) if 2 * (L / K) < L: if L <= (2 * K): print(0) else: print(K * cnt) else: print((K * cnt) -1)