Sorry, but what do you mean with "But the question type I have is free text not numerical input, and secondly, I have a list of 40 inputs,"?
40 possible 3 letter post codes?
You are just giving bits of information at a time. Tpartner gave you a general solution.
Ideally you post an example of what you have done so far (containing only the relevant questions) as LSS.
However, here is how I understood it and what I would do:
Q1: short free text, limited to 3 digits.
Q2: Equation type question, reading in the code, checking if it is part of one of the 40 possible 3 letter post codes. Depending on the version of limesurvey you use (which you have not mentioned), quotas work directly with equation type questions. So lets say West Brookly in has the post codes q1w, q2w, q3w. So you check if the code provided is one of these three codes. If so, you just write into the equation question "1" (which now stands for West Brooklyn).
If not, then you check if it is q1e, q2e or q3e (just an example, I have not idea how the postal codes work) and see if the person fits into the quota of East Brooklyn, so if this is the case you write into the equation question "2" for East Brooklyn.
Then you set your quota based in these codes in the equation question.
Code:
{if(Q1=="q1w" OR Q1=="q2w" OR Q1=="q3w", 1, if(Q1=="q1e" OR Q1=="q2e" OR Q1=="q3e", 2, 3))}
Just to give you an idea. the last 3 is written if the code does not match any of the codes for East or West Brooklyn, so there you set the zero quota on 3.
Of course, the final solution depends very much on how your setup really looks like, which you never really mentioned here.
And I am sure that more experienced people will find probably an easier and more elegant way then mine (which by the way is not tested in any way and may contain errors, it is just an example).