Input: Sentence: 'A herd of sheep with man and dog next to water'. Count the number of nouns in this sentence.
Output: 5