Find the positive integer $n$ such that:
\[
\underbrace{f(f(\cdots f}_{2013 \ f\text{'s}}(n)\cdots ))=2014^2+1
\]
where $f(n)$ denotes the $n$th positive integer which is not a perfect square.

Let's think step by step and output the final answer within \boxed{}.
user