Maybe

=COUNTIFS($B$1:$B$19,B2,$A$1:$A$19,"<>"&A2)

Note: the formula can't tell how many ID, just tell have 'another' ID (value 1 or more)

Regards.