  In 1947 Nathan Fine gave a beautiful product for the number of binomial
coefficients $\binom{n}{m}$, for $m$ in the range $0 \leq m \leq n$, that are
not divisible by $p$. We give a matrix product that generalizes Fine's formula,
simultaneously counting binomial coefficients with $p$-adic valuation $\alpha$
for each $\alpha \geq 0$. For each $n$ this information is naturally encoded in
a polynomial generating function, and the sequence of these polynomials is
$p$-regular in the sense of Allouche and Shallit. We also give a further
generalization to multinomial coefficients.
