For a positive integer $n > 1$, let $g(n)$ denote the largest positive proper divisor of $n$ and $f(n) = n - g(n)$. For example, $g(10) = 5$, $f(10) = 5$ and $g(13) = 1$, $f(13) = 12$. Let $N$ be the smallest positive integer such that $f(f(f(N))) = 97$. Find the largest integer not exceeding $\sqrt{N}$.

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