l,k = map(int, input().split()) result = 0 if l > (k *2) : if l %k == 0 : count = (l // (k*2)) -1 result = count * k else : count = l // (k*2) result = count * k print (result)