Need help with registration form

Need help with registration form

Complete noob here. I am trying to make a registration form for a 2 hour school event, that will consist of students choosing  2 separate one hour sessions from 40 choices. Each session has a different number of students they can handle, so I need to limit the number of registrants for certain choices or remove/cap it at a certain number. How do I do this? What would be the code? Thanks in advance.