Underbrace part of an expression

Is there a way to only have an underbrace for part of an expression? I want to only have the brace below the 0's but if I move the 5 out of the \underbrace then a gap between the 5 and the 0 appears.

• Welcome to TeX.SE.
– Mico
Feb 16 at 20:55

$5{\underbrace{00\dots0}_{\text{n 0's}}}^3 \quad\text{vs.}\quad 5\underbrace{00\dots0}_{\text{n 0's}}{}^3$