Input: Sentence: 'Three people on horses on a beach with a dog'. Count the number of nouns in this sentence.
Output: 4