# coding: utf-8 if __name__ == '__main__': l, k = [int(i) for i in input().split()] quotient = l // (k * 2) remainder = l % (k * 2) if remainder == 0: quotient -= 1 result = k * quotient print(result)