Sum if two different values exist in same column for same id
I've a table of data where multiple rows exist for the same item, e.g.
Device Value
1 A 1 B 2 A 3 A 3 B
I want to sum the total number of situations where a unique device has rows of data that contain both A and B, so the result to the above data would be 2