I'm not sure exactly what you want or where you're getting the line, but look at $numtok. That will tell you how many "words" are in the line. Here's an example, and hopefully you can use it where you need it. I don't know if you want this for an on TEXT event, or in an alias reading from a text file.
Code:
alias wordcount {
echo -a $numtok($1-,32)
}

*usage:
/wordcount This is a sentence.

This would echo "4", since there are four words separated by spaces (ASCII character 32) in that sentence. Look at /help Token Identifiers for help on replacing tokens or getting a specific token in text.