This solution uses the formula of the questioner Statto of this discussion: Restarting and resuming a running total for multiple values
One formula for scenarios with and without blanks:
=SUM(N(MAP(A2:A11,LAMBDA(a,COUNTIFS(INDEX(A2:A11,1):a,a)))>1))
=SUM(N(MAP(B2:B14,LAMBDA(a,COUNTIFS(INDEX(B2:B14,1):a,a)))>1))