Find all positive integers $n$ for which $$S(n^2)+S(n)^2=n$$where $S(m)$ denotes the sum of digits of $m$.
Source: Belarusian National Olympiad 2021
Tags: number theory
Find all positive integers $n$ for which $$S(n^2)+S(n)^2=n$$where $S(m)$ denotes the sum of digits of $m$.