5. Given that $A$ took an integer number of hours to travel from location A to location B, and the number of kilometers $A$ walks per hour is the same as the number of hours he took to travel from location A to location B. $B$ walks 2 kilometers per hour from location A to location B, and rests for 1 hour after every 4 kilometers, and it took him a total of 11 hours. Then the distance between location A and location B is $\qquad$ kilometers.
$B$ is equivalent to walking 4 kilometers each for the first 9 hours, and then walking 4 kilometers for the next 2 hours, totaling 16 kilometers in 11 hours; for $A$, the distance between locations A and B is a perfect square number, which satisfies the problem's conditions.

Therefore, the distance between locations A and B is 16 kilometers.