5. Given 2023 identical-looking coins, among which there are two counterfeit coins of the same weight, and the remaining 2021 coins are genuine and of the same weight. The counterfeit coins weigh differently from the genuine coins. Now, you only want to know whether a counterfeit coin is heavier or lighter than a genuine coin (without distinguishing which is the counterfeit), using a balance scale to solve this problem. Then, the minimum number of weighings required is ( ).
(A) 2
(B) 3
(C) 4
(D) More than 4
5. B.

Take out a coin and place it elsewhere, then divide the remaining coins into two groups $A$ and $B$ (each group has 1011 coins), and let $W(N)$ represent the total weight of the coins in group $N$.

For the first weighing, compare $W(A)$ with $W(B)$. Assume $W(A) \geqslant W(B)$, then divide group $A$ into three subgroups $C$, $D$, and $E$ (each subgroup has 337 coins), and perform two more weighings to compare $W(C)$ with $W(D)$, and $W(D)$ with $W(E)$. The following discussion is divided into two cases.
(1) When $W(A)=W(B)$, group $A$ and group $B$ each contain one counterfeit coin. Among the three subgroups $C$, $D$, and $E$, there is one subgroup that has a different weight from the other two. This subgroup is heavier, so the counterfeit coin is heavier. Otherwise, the counterfeit coin is lighter.
(2) When $W(A)>W(B)$, then only one of the groups $A$ or $B$ contains a counterfeit coin.
(i) If $W(C)=W(D)=W(E)$, then group $A$ does not contain a counterfeit coin, and group $B$ contains one or two counterfeit coins. Therefore, the counterfeit coin is lighter.
(ii) If $W(C)$, $W(D)$, and $W(E)$ are not all equal, then group $A$ contains at least one counterfeit coin, and group $B$ does not contain a counterfeit coin. Therefore, the counterfeit coin is heavier.