The masses of blocks $A$ and $B$ are $m$ and $M$ respectively. Between $A$ and $B$, there is a constant frictional force $F$ and $B$ can slide on a smooth horizontal surface. $A$ is set in motion with velocity while $B$ is at rest. What is the distance moved by $A$ relative to $B$ before they move with the same velocity?