It is not necessary for the table to be sorted for the following formula to return a 1 for each unique value present.
assuming the table range for the data presented in the question is A1:B7 enter the following formula in Cell C1:
=IF(COUNTIF($B$1:$B1,B1)>1,0,COUNTIF($B$1:$B1,B1))
Copy that formula to all rows and the last row will contain:
=IF(COUNTIF($B$1:$B7,B7)>1,0,COUNTIF($B$1:$B7,B7))
This results in a 1 being returned the first time a record is found and 0 for all times afterwards.
Simply sum the column in your pivot table