from bisect import bisect_left S = input().strip() N = len(S) S = "0"+S D = {} for i in range(1,N+1): if S[i] not in D: D[S[i]] = [0] D[S[i]].append(i) dp = [0]*(N+1) dp[1] = 1 if N>=2: if S[1]==S[2]: dp[2] = 3 else: dp[2] = 4 for i in range(3,N+1): ind = bisect_left(D[S[i]],i) dp[i] = 2*dp[i-1]-dp[i-2]+i-D[S[i]][ind-1] print(dp[N]*2/(N*(N+1)))