What you are looking to do is called a short sale. The level of difficulty depends on who the mortgage is with. Some operate like they don't realize the current housing situation. Some are realistic.
You should get two sources for help on this. First is a real estate attorney, second is a real estate agent who knows enough to know what they don't know! So base on that here are some opinions of what you can do.
You have to begin with request for a short sale from the current owners to each of the mortgage holders. The paperwork must be filled out correctly and an actual offer has to be made before they will respond. Part of the paper work is a letter explaining the reason for the request. There must be a compelling reason for them to grant the short sale. Again, depending on who the mortgage holders are; they may not respond, may respond in a few weeks, or may respond in a few months!
Part of the offer and paperwork should include a "Mortgage to be recorded as satisfied, and mortgage and promissory note to be discharged". A real estate attorney could provide you with the actual language. The object of this clause is to protect the seller's credit to some extent and stops the mortgage holder from further action to recover the money not paid. Patience is the key work when trying to do a short sale.
The answer to how much depends, again, on who the mortgage holders are. The second mortgage holder typically gets wiped out on foreclosure, so they will be very likely to take a small percent owed. The other thing to look at based on this is what the first mortgage pay off is. They may not consider a short sale if they feel they can sell the house for what is owed to just them.
Lastly, if the house does get foreclosed on, watch for the sheriff's sale. That will determine the redemption amount the original owner must pay to recover the house. You may be able to pay the original owner a few thousand dollars and buy his right of redemption.