from collections import defaultdict S=input() N=len(S) R=defaultdict(int) R_sum=0 X=0 for i,s in enumerate(S,1): R_sum+=i-R[s] R[s]=i X+=R_sum print(X/(N*(N+1)//2))