The set of all positive integers is the union of two disjoint subsets {f(1),f(2),,f(n),}\{f(1), f(2), \ldots, f(n), \ldots\}, {g(1),g(2),,g(n),}\{g(1), g(2), \ldots, g(n), \ldots\}, where

f(1)<f(2)<<f(n)<,f(1) < f(2) < \cdots < f(n) < \cdots, g(1)<g(2)<<g(n)<,g(1) < g(2) < \cdots < g(n) < \cdots,

and

g(n)=f(f(n))+1 for all n1.g(n) = f(f(n)) + 1 \text{ for all } n \geq 1.

Determine f(240)f(240).