There are two integers: $A, B$. Given the below four allowed operations (and only them):
$A+1$, $A-1$, $\sqrt{A}$, $A^2$
Also, it is only allows to take the square root of $A$ when this square root yields a natural number.
How can one find the minimum amount of operations in order to get from $A$ to $B$?