Let S(n)S(n)S(n) be the sum of the digits in the decimal representation of the number nnn. Find S(S(S(S(20172017))))S\left(S\left(S\left(S\left(2017^{2017}\right)\right)\right)\right)S(S(S(S(20172017)))).