In rectangle $ABCD,$ $P$ is a point on side $\overline{BC}$ such that $BP = 16$ and $CP = 8.$  If $\tan \angle APD = 3,$ then find $AB.$

Let's think step by step and output the final answer within \boxed{}.
user