#!/usr/bin/env python3 #fileencoding: utf-8 L, K = [int(i) for i in input().strip().split(" ")] if L%(K*2) != 0: print(L//(K*2) * K) else: print((L//(K*2)-1) * K)