Well, the S[x] is just the remainder Mod 9.
Therefore, S[xy] = S[x]*S[y].
And what possible values mod 9 could "a" have?
Let's first consider the powers (mod 9) of any number which equals 2 mod 9.:
2*2 mod 9 = 4
2^3 mod 9 = 8
2^4 mod 9 = 2*8 mod 9 = 7
2^5 mod 9 = 2*7 mod 9 = 5
2^6 mod 9 = 2*5 mod 9 = 1
2^7 mod 9 = 2*1 mod 9 = 2
so the powers of 2 mod 9 are 2,4,8,7,5,1,and repeating thereafter with period 6
For all numbers, the powers (mod 9) are:
0: 0, 0, 0 , etc.
1: 1, 1, 1, etc.
2: 2, 4, 8, 7, 5, 1, repeating thereafter with period 6
3: 3, 0, 0, 0, etc.
4: 4, 7, 1, repeating thereafter with period 3
5: 5, 7, 8, 4, 2, 1, repeating thereafter with period 6
6: 6, 0, 0, 0, etc.
7: 7, 4, 1 repeating thereafter with period 3
8: 8, 1, 8, 1, repeating thereafter with period 3
Note that 2 appears in only 2 of these lists. So, the only values of a which could possibly = 2 mod 9 when raised to the a-th power are = (mod 9) to 2 or 5.
If a = 2 mod 9, then the power it is raised to (which also a) must be 1, or 6, or 13, or 1 mod 6 (because of the repeating period).
But, in order to equal 2 mod 9, a (mod 18) must equal 2 or 11.
And, in order to equal 1 mod 6, a (mod 18) must equal 1 or 7 or 13.
Therefore a is not equal to 2 mod 9.
Therefore, a must equal 5 mod 9.
And the power it is raised to (which also a) must equal 5 mod 6.
And these two things can only happen simultaneously if a (mod 18) = 5.
Therefore, any and all positive numbers which equal 5 mod 18 will satisfy S[a^a] = 2
And the solution to the puzzle is the smallest perfect power which equals 5 mod 18, (unless I've made a mistake).
And that's as far as I've gotten.
Although it wouldn't be hard to work out (using the method above) to work out the smallest such number. m and k must both be less than 18, and m is not divisible by a factor of 18 (2 or 3),
so m must be 5 or 7 or 11 or 13 or 17. I'll finish this after supper.