en2asc = lambda s: ord(s) - 97 S = input() L = len(S) cur = [-1] * 26 dp = [0] * (L + 1) for i, s in enumerate(S): x = en2asc(s) dp[i + 1] = dp[i] + i - cur[x] cur[x] = i ans = sum(dp) * 2 / ((L + 1) * L) print(ans)