Input: Sentence: 'A dog stretching on a ledge near water'. Count the number of nouns in this sentence.
Output: 3