#include "bits/stdc++.h" using namespace std; #define Rep(i,n) for(int i=0;i<(int)(n);i++) #define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++) #define REP(i,n) for(ll i=0;i<(ll)(n);i++) #define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--) #define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++) #define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--) #define put(a) cout< P; template inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; } template inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; } vector > calcNext(const string& S) { int n = (int)S.size(); vector > res(n + 1, vector(26, n)); for (int i = n - 1; i >= 0; --i) { for (int j = 0; j < 26; ++j) res[i][j] = res[i + 1][j]; res[i][S[i] - 'a'] = i; } return res; } int main() { string s; cin >> s; vector> cn = calcNext(s); int n = s.size(); ll a = n*(n+1)/2; //ll b = 0; double res = 0; REP(i, n) { ll b = 0; REP(j, 26) { if (cn[i][j] != n) { b += n - cn[i][j]; } } res += (double)b / a; } cout << setprecision(20) << res << endl; return 0; }