Solution:
we are given that
Tory goes shopping and buys pencils and notebooks
Tory buys a total of 8 items, p of which are pencils.
So Number of Notebooks

Also we are given that each pencil costs $0.29 and each notebook costs $2.59.
So Total spending on pencil can be given by the expression=$0.29P
The Total spending on the Notebook can be given by the expression=$2.59(8-P)
Total spending all together=$0.29P+$2.59(8-P)
Since we are given that Tory's bill is $9.22
So we can write

Hence Tory Buys 5 Pencils.