n,m=map(int, input().split()) mogu_num=n//(m*2) if n%(m*2) == 0: if mogu_num < 1: mogu_num = 0 else: mogu_num -= 1 print(m*mogu_num)