def main(): L, K = list(map(int, input().split())) limit_yuu_eat = L // (2 * K) if L % (2 * K) == 0: limit_yuu_eat -= 1 print(limit_yuu_eat * K) main()