ceiling(700/40) = ceiling(17.5) = 18 . . . . ceiling(x) is the smallest integer ≥ x.
The smallest integer multiple of 40 that is larger than 700 is 18.
The number of packages of buns will be 18*5 = 90.
The number of packages of hotdogs will be 18*4 = 72.
_____
These numbers will ensure that you have 20 bun/hotdog combinations left over. If you want to minimize leftovers, you would use 88 packages of buns and 70 packages of hotdogs. That would give you 4 buns and no hotdogs left over.