L, K = map(int, input().split()) twice_K = K * 2 if L <= twice_K or L % twice_K == 0: print(0) else: count = L // twice_K print(K * count)