Minimum operations

Can anyone help me with this question?
link is https://www.hackerearth.com/practice/basic-programming/input-output/basics-of-input-output/practice-problems/algorithm/step-conversion/description/.

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