Ms. Yoto is putting together bags of fruit that contain 1 pear for every 2 apples. How many apples are there in a bag if there is a total of nine pieces of fruit (using algebraic formulas).