MOD = 10 ** 9 + 7 INF = 10 ** 12 import sys sys.setrecursionlimit(1000000) dy = (-1,0,1,0) dx = (0,1,0,-1) from itertools import permutations from math import gcd def main(): s = input() n = len(s) dp = 0 dic = {} ans = 0 for i in range(1,n + 1): if s[i - 1] in dic: dp += i - dic[s[i - 1]] dic[s[i - 1]] = i else: dic[s[i - 1]] = i dp += i ans += dp ans /= (n + 1)*n//2 print(ans) if __name__ =='__main__': main()