Do you want to check only for contiguous triplets of the form (a, b, b)? Based on your example, that doesn't seem to be the case. Then, you can just count the number of unique values and repeated values and multiply them.
In the example [5,6,7,3,3,3],
count_of_unique_vals = 3 # 5, 6 and 7
count_of_repeated_vals = 1 # 3
count_of_triplets = 3 # 3*1, or len(unique_vals) * len(repeated_vals)