First note that: :$1^2 + 9^2 + 9^2 = 163$ :$9^2 + 9^2 + 9^2 = 243$ and it can be seen that for a positive integer $m$ larger than $199$, $\map f m < m$. Thus it is necessary to investigate numbers only up as far as that. Starting from the bottom, we have that: :$\map f 1 = 1^2 = 1$ and so $\sequence {S_1} = 1, 1, 1, \ldots$ We note the sequence: {{begin-eqn}} {{eqn | ll= \map f 4       | lo= =       | l = 4^2       | r = 16 }} {{eqn | ll= \map f {16}       | lo= =       | l = 1^2 + 6^2       | r = 37 }} {{eqn | ll= \map f {37}       | lo= =       | l = 3^2 + 7^2       | r = 58 }} {{eqn | ll= \map f {58}       | lo= =       | l = 5^2 + 8^2       | r = 89 }} {{eqn | ll= \map f {89}       | lo= =       | l = 8^2 + 9^2       | r = 145 }} {{eqn | ll= \map f {145}       | lo= =       | l = 1^2 + 4^2 + 5^2       | r = 42 }} {{eqn | ll= \map f {42}       | lo= =       | l = 4^2 + 2^2       | r = 20 }} {{eqn | ll= \map f {20}       | lo= =       | l = 2^2 + 0^2       | r = 4 }} {{end-eqn}} Hence any $m$ in the set $\set {4, 16, 20, 37, 42, 58, 89, 145}$ stays within that sequence, which we will refer to as $\mathcal S$. It remains to test the rest. Let $\mathcal T$ be the set of integers $m$ for which $S_m$ ends up either in $\mathcal S$ or $1$. Then the elements of $\mathcal S$ are all in $\mathcal T$, as is $1$. If $m \in \mathcal T$, then any integer $m'$ whose non-zero digits are the same as those of $m$ is also in $\mathcal T$. Thus: :$2, 10, 24, 40, 61, 73, 85, 98, 100, 106 \in \mathcal T$ We use the notation: :$a \to b \to c$ to denote: :$\map f a = b, \map f b = c$ and work progressively through $\Z_{>0}$. So: {{begin-eqn}} {{eqn | l = 3 \to 9 \to 81 \to 65 \to 61       | o = \in       | r = \mathcal T }} {{eqn | ll= \leadsto       | l = 18, 30, 56, 90       | o = \in       | r = \mathcal T }} {{eqn | l = 5 \to 25 \to 29 \to 85       | o = \in       | r = \mathcal T }} {{eqn | ll= \leadsto       | l = 50, 52, 92       | o = \in       | r = \mathcal T }} {{eqn | l = 6 \to 36 \to 45 \to 41 \to 17 \to 50       | o = \in       | r = \mathcal T }} {{eqn | ll= \leadsto       | l = 14, 54, 60, 63, 71       | o = \in       | r = \mathcal T }} {{eqn | l = 7 \to 49 \to 97 \to 130 \to 10       | o = \in       | r = \mathcal T }} {{eqn | ll= \leadsto       | l = 13, 31, 70, 79, 94       | o = \in       | r = \mathcal T }} {{eqn | l = 8 \to 64 \to 52       | o = \in       | r = \mathcal T }} {{eqn | ll= \leadsto       | l = 46, 80       | o = \in       | r = \mathcal T }} {{eqn | l = 11 \to 2       | o = \in       | r = \mathcal T }} {{eqn | l = 12 \to 5       | o = \in       | r = \mathcal T }} {{eqn | ll= \leadsto       | l = 21        | o = \in       | r = \mathcal T }} {{eqn | l = 15 \to 26 \to 40       | o = \in       | r = \mathcal T }} {{eqn | ll= \leadsto       | l = 51, 62       | o = \in       | r = \mathcal T }} {{eqn | l = 19 \to 82 \to 68 \to 100       | o = \in       | r = \mathcal T }} {{eqn | ll= \leadsto       | l = 28, 86, 91       | o = \in       | r = \mathcal T }} {{eqn | l = 22 \to 8       | o = \in       | r = \mathcal T }} {{eqn | l = 23 \to 13       | o = \in       | r = \mathcal T }} {{eqn | ll= \leadsto       | l = 32       | o = \in       | r = \mathcal T }} {{eqn | l = 27 \to 53 \to 34 \to 25       | o = \in       | r = \mathcal T }} {{eqn | ll= \leadsto       | l = 35, 43, 72       | o = \in       | r = \mathcal T }} {{eqn | l = 33 \to 18       | o = \in       | r = \mathcal T }} {{eqn | l = 38 \to 73       | o = \in       | r = \mathcal T }} {{eqn | ll= \leadsto       | l = 83       | o = \in       | r = \mathcal T }} {{eqn | l = 39 \to 90       | o = \in       | r = \mathcal T }} {{eqn | ll= \leadsto       | l = 93       | o = \in       | r = \mathcal T }} {{eqn | l = 44 \to 32       | o = \in       | r = \mathcal T }} {{eqn | l = 47 \to 65       | o = \in       | r = \mathcal T }} {{eqn | ll= \leadsto       | l = 74       | o = \in       | r = \mathcal T }} {{eqn | l = 48 \to 80       | o = \in       | r = \mathcal T }} {{eqn | ll= \leadsto       | l = 84       | o = \in       | r = \mathcal T }} {{eqn | l = 55 \to 50       | o = \in       | r = \mathcal T }} {{eqn | l = 57 \to 74       | o = \in       | r = \mathcal T }} {{eqn | ll= \leadsto       | l = 75       | o = \in       | r = \mathcal T }} {{eqn | l = 59 \to 106       | o = \in       | r = \mathcal T }} {{eqn | ll= \leadsto       | l = 95       | o = \in       | r = \mathcal T }} {{eqn | l = 66 \to 72       | o = \in       | r = \mathcal T }} {{eqn | l = 67 \to 85       | o = \in       | r = \mathcal T }} {{eqn | ll= \leadsto       | l = 76       | o = \in       | r = \mathcal T }} {{eqn | l = 69 \to 117 \to 51       | o = \in       | r = \mathcal T }} {{eqn | ll= \leadsto       | l = 96       | o = \in       | r = \mathcal T }} {{eqn | l = 77 \to 98       | o = \in       | r = \mathcal T }} {{eqn | l = 78 \to 113 \to 11       | o = \in       | r = \mathcal T }} {{eqn | ll= \leadsto       | l = 87       | o = \in       | r = \mathcal T }} {{eqn | l = 88 \to 128 \to 69       | o = \in       | r = \mathcal T }} {{eqn | l = 99 \to 162 \to 41       | o = \in       | r = \mathcal T }} {{end-eqn}} {{Finish|It's relatively easy to show that each starting number will decrease up to at least $170$ by considering that the squares of digits will be smaller than the number itself up to around that point (considering $9^2 + 9^2 {{=}} 162$). So manual work is needed "only" below that...<br/>Can it actually be shown that if $m$ is of 3 or more digits, then $\map f m < m$? If so then job done.<br/>Yes, by a series of bounds: $3 \cdot 9^2 {{=}} 243, 2^2 + 2 \cdot 9^2 {{=}} 166, 1 + 6^2 + 9^2 {{=}} 118, 1 + 1 + 9^2 < 100$. Not sure how to formulate nicely, though. For numbers of $n > 3$ digits, $n 9^2 < 10^{n - 1}$}}