Let the state of the circuit be represented as (QA,QB), where:
QA is the state/output of the first (left) flip-flop.
QB is the state/output of the second (right) flip-flop.
From the circuit diagram, the inputs to the D flip-flops are:
DA=in
At the next active clock edge, the next state (QA+,QB+) is given by:
QA+=DA=inQB+=DB=QA
For a state (QA,QB) to transition back to itself (i.e., a self-loop), we require:
QA+=QA⟹in=QA
QB+=QB⟹QA=QB
Thus, a self-loop exists if and only if QA=QB and the input applied is in=QA:
For state 00 (QA=0,QB=0): With in=0, next state is (0,0)=00 (Self-loop exists).
For state 11 (QA=1,QB=1): With in=1, next state is (1,1)=11 (Self-loop exists).
For state 01 (QA=0,QB=1): Next state is (in,0), which can never be 01.
For state 10 (QA=1,QB=0): Next state is (in,1), which can never be 10.
Therefore, exactly 2 states (00 and 11) have a transition back to themselves.