Write out the factors of 7 and sort them. The largest perfect square should pop right out from that.
7 = 1 * 2 * 3 * 2*2 * 5 * 2*3 * 7
= 2*2*2*2 * 3*3 * 5 * 7
Pull out all the pairs of factors you can, and you get
S = 2*2*2*2*3*3 = 144 = 12^2
That's the answer.