count word for pattern