3. Let $a$ be an integer, and $\frac{a^{2}-a+3}{a^{3}-3 a^{2}+1}$ is also an integer. Then the number of all such $a$ is ( ).
(A) 2
(B) 3
(C) 4
(D) 5
3.B.

Obviously, when $a=0,1,3$, the condition is satisfied, and when $a=2$, it does not satisfy the condition.
If $a \geqslant 4$, then
$$
\begin{array}{l}
a^{3}-3 a^{2}+1=a^{2}(a-3)+1 \\
>a^{2}(a-3) \geqslant a^{2}>a^{2}-a+3 .
\end{array}
$$

If $a a_{1}^{2}+a_{1}+3 \text {. }
$$

Moreover, when $a_{1}=1$, the requirement is not met.
Therefore, the integers $a$ that satisfy the condition are $0,1,3$.