Assuming your sample data lies in the range A2:C6, then try this......

=SUMPRODUCT((ISNUMBER(MATCH(B2:B6,A2:A6,0)))*C2:C6)