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