import sequtils,strutils,math,algorithm var S = stdin.readline A : array['a'..'z', seq[int]] P : array['a'..'z', int] ans : float64 = 0.0 q = 0.0 for c in 'a'..'z': A[c] = @[] for i, c in S: A[c].add(i) for i in 0..S.high: var B = newSeq[int](0) for c in 'a'..'z': if A[c].high < P[c]: continue B.add(A[c][P[c]] - i) if c == S[i]: P[c] += 1 for j in 0..B.high: ans += (S.high - i + 1 - B[j]).float64 q += (S.high - i + 1).float64 echo ans / q