If $a^2 < n < (a+1)^2$, then the square gaps around $n$ have size $2a-1, 2a+1, 2a+3, \dots$. Due to parity, the square gap between $n + S(n)$ and $n - S(n)$ ends up having size at least $4a \ge 4(\sqrt{n} - 1)$. As such, it must follow that $2S(n) \ge 4(\sqrt{n} - 1)$ due to square gaps. We can check that this holds on $1000 \ge n \le 100$, at which point the bound $S(n) \le 9 \left\lceil \log_{10}(n) \right\rceil$ implies the result for all larger $n$.
As such, it follows by bounding that $n \le 100$. Let $n = \overline{ab}$. Then we get that $11a+2b, 9a$ are both perfect squares, so $a$ must be a perfect square. As such, checking gives $n = 2, 8, 17$ as the only solutions.