Input: Sentence: 'A boat flies its flag while sailing just off a pier'. Count the number of nouns in this sentence.
Output: 3