S = input() res = 0 l = [-1]*26 for i in range(len(S)): p = l[ord(S[i])-97] if p!=-1: res += (i-p)*(len(S)-i) else: res += (i+1)*(len(S)-i) l[ord(S[i])-97] = i print(2*res/((1+len(S))*len(S)))