patterns stuff; binary search - count occurrences