You should not go throw this much deep, as your question was to know how to increase the amount.
Add one var which is count as object and put it in a loop which will run according to your criteria.
And then put give the maximum condition about finding the values.
You can try this in c,c++ by using ++ operator before the var.