If you are working in base 10 you have the number of digits of $x$ as $\lfloor \log_{10} x\rfloor+1$. Assume logs are to base 10 to simplify notation.
The number of digits you need is then, as you calculate:
$\lfloor \log {2^p}\rfloor+1+\lfloor \log {5^p}\rfloor+1 = \lfloor p\log {2}\rfloor+1+\lfloor p\log {5}\rfloor+1$
Aside from the fact that you might have a rounding error of 1, you can then use $p\log2+p\log5=p\log{10}=p$.
So your answer will be $p+2 \text { or } p+1$
Then note, as Henry points out, that the logs are related - the floor function always reduces the total by 1 and never by zero, because the logs are not rational, so the answer is $p+1$