How to put a constraint in the second question based in an input from the first question?

Have you gone through our support article Limiting Responses with Validation Criteria? It should solve your issue.

As a workaround, this post discussed previously should be helpful for you: