list1 = list(map(int, input().split())) L= list1[0] K = list1[1] if L % (K*2) == 0: print((L // (K*2) -1)*K) else: print((L // (K*2))*K)