Here we are given two distinct numbers: $n$ and $m$, with $1 \leq n, m \leq 10^4$. We start from $n$ and count the steps required to turn it into $m$, but we can only use two operations. At each step, you can either set $n = 2n$ or $n = n - 1$, either step costs $1$. A solution is guaranteed to be possible.
At first it might seem possible to use a heuristic to deterministically compute the best option at each step, but it is not so simple. Once you make that realization, you might be thinking dynamic programming, but there is an even easier alternative.
Model the task as a graph problem, where the nodes are values, and edges are operations. Each node can have up to two outgoing edges, one connecting with the $n - 1$ node, and one connecting with the $2n$ node. Then, by exploring the graph breadth-first, with a step size of $1$, we will guarantee ourselves to reach $m$ in the minimum number of steps.
Approach is identical in other languages like Python.