5. Person A and Person B start walking towards each other at a constant speed from points $A$ and $B$ respectively, and they meet for the first time at a point 700 meters from $A$; then they continue to walk, with A reaching $B$ and B reaching $A$, and both immediately turning back, meeting for the second time at a point 400 meters from $B$. Then the distance between $A$ and $B$ is meters.
5. Let the distance between places $A$ and $B$ be $x$ meters, the time for the first meeting be $t$, and the time for the second meeting be $2t$. According to the problem,
$$
\frac{700}{t}=\frac{x-700+400}{2 t} \text{, solving for } x=1700 \text{. }
$$