# -*- coding: utf-8 -*- L, K = map(int, input().split()) remainder = L % (2*K) amount = 0 number = L // (2*K) if remainder == 0: amount = (number-1)*K else: amount = number*K print(amount)