Minimum operations

Can anyone help me with this question?
link is Programming tutorials, Coding problems, and Practice questions.

My logic: For k>m . we only have to decrease the number b.
For k=m, Answer is 0 of course.
For k<m, unable to find any logic