import math l = list(map(int, input().split())) k = l[1] l = l[0] print((math.ceil(l / (k * 2)) - 1) * k)