#include #include using namespace atcoder; using namespace std; using ll=long long; using ld=long double; ld pie=3.141592653589793; ll mod=998244353; ll inf=100990999999999909; int main(){ string s; cin >> s; vectormemo(100,-1); ll ans=0; for (ll i = 0; i < s.size(); i++) { mapmm; ll now=0; memo[s[i]-'a']=max(memo[s[i]-'a'],i); for (char c = 'a'; c <='z'; c++) { if (memo[c-'a']!=-1) { now++; mm[memo[c-'a']]++; } } ll pre=-1; for(auto v:mm){ ans+=now*(v.first-pre); pre=v.first; now--; } } ll n=s.size(); ll x=(n*(n+1))/2; ld y=ans; ld z=x; cout << setprecision(100) << y/z << endl; }