Need Help with Dynamic Form Calculation in Gravity Forms

I’m reaching out because I’m having a bit of trouble with a form I’m trying to create, and I could really use some guidance.

Here’s the scenario: I’m working on a form where users can place orders for events. In the first step of the form, users specify the number of attendees they’re ordering for. Then, in the next step, they need to choose between two menu options, let’s call them “Menu A” and “Menu B,” and specify the quantity for each menu option.

For example, if a user is ordering for 36 people and selects 20 for Menu A, I want the form to automatically calculate and fill in that the remaining 16 attendees have chosen Menu B.

But more important. It must be impossible to order more than 36 of both menus combined. The total can only be 36. Not more, not less.

I’ve been trying to figure out how to set this up dynamically within Gravity Forms, but I do’t know where to start. Can anyone offer some advice or point me in the right direction? I’d greatly appreciate any insights or suggestions you might have!