An explanation of why the answer to the first example is $14$ can be seen in the image above.

In the second example, the answer is $3$, because the rook can only move one position up and two positions to the right.