count words for pattern