Input: Sentence: 'Two people are riding a motorcycle with a flag attached to the back'. Count the number of nouns in this sentence.
Output: 4