function that looks for the first value n for which length of f(n) >= some length