Counting occurrences of text in input