counting number occurrences - brute force solution