If I paid 12z for something and received 27s in change, how much did the item cost, given that 5s = y and

10y = z ?

cost = 12z-27s

Now plug in whatever other quantities you want to use.