According to the first law of thermodynamics, the amount of work done by a heat engine equals the amount of

Awork done on the engine.
Bwaste heat it produces.
Cthermal energy added to the engine minus the waste heat.
Dthermal energy added to the engine plus the waste heat.