Input: Sentence: 'A book lying on a bed next to a pillow'. Count the number of nouns in this sentence.
Output: 3