#include using namespace std; #define MOD 1000000007 //#define MOD 998244353 #define INF 1145141919810893364 typedef pair PP; typedef long long ll; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } #define int ll #define setdouble setprecision #define REP(i,n) for(int i=0;i<(n);++i) #define OREP(i,n) for(int i=1;i<=(n);++i) #define RREP(i,n) for(int i=(n)-1;i>=0;--i) #define GOODBYE cout << -1 << endl;return 0 #define MM <<" "<< #define Endl endl signed main(void){ string S; cin >> S; vector K[30]={}; int N=S.size(); double Ans=0; int B=0; REP(i,N){ K[(int)(S[i]-'a')].push_back(i); } REP(i,N){ B+=(i+1)*(N-i); } REP(i,26){ REP(j,((int)K[i].size())-1){ int l=K[i][j],r=K[i][j+1]; B-=(l+1)*(N-r); } } Ans=B; //cout << Ans << endl; Ans/=N; Ans*=2; Ans/=N+1; printf("%.8f\n",Ans); return 0; }