I think you'll need to provide more info, what exactly do you need? It could be as simple as adding both totals together and deducting from 24 with a min in there to show zero, such as =MIN(0, total1 + total2)

but we really need more info before giving a definitive answer. Can you fill out some of the expected results?