Or you can just look at the N section of the sort and all the numbers between each N will be free.
1000 N
1001 N
1344 N
1345 N
So 1002 to 1343 Inclusive must be a Y So just put a formula in another column that takes the number above away from its row which will give you the number of free numbers between them - then just scroll down the list and pick one big enough for your purposes.