calculate the number of words