l,k=map(int,input().split()) c = -(-l//(2 * k)) print((c - 1) * k)