In order to determine how many packages of diapers you can buy, it is only necessary to divide the total money you have, between the price of each package.
You have:
available money = 40$
package cost = 8$
Then, you calculate the quotient between available money and package cost:
Hence, you can buy 5 packages of diapers with 40$