5. Given that $a$ is a prime number less than 2012, and 2012 $-a$ is coprime with $a$. Then the number of $a$ that satisfies the condition is ( ).
(A) 1003
(B) 1004
(C) 1005
(D) 1006
5. B.

If $a$ is even, then $2012-a$ is also even. In this case, $a$ and $2012-a$ have a common divisor of 2, so they are not coprime. Therefore, $a$ cannot be even and must be odd.
Since $2012=503 \times 4$, and 503 is a prime number, we have
$$
a \neq 503 \times 1 \text { and } 503 \times 3 \text {. }
$$

There are 1006 odd numbers in the range $1 \sim 2012$, so the number of $a$ that meet the conditions is
$$
1006-2=1004 \text {. }
$$