#include #define rep(i,n) for(int i = 0; i < (n); ++i) #define srep(i,s,t) for (int i = s; i < t; ++i) #define drep(i,n) for(int i = (n)-1; i >= 0; --i) using namespace std; typedef long long int ll; typedef pair P; #define yn {puts("Yes");}else{puts("No");} #define MAX_N 200005 int main() { string s; cin >> s; ll n = s.size(); vector v[26]; rep(i,26)v[i].push_back(0); rep(i,n){ v[s[i] - 'a'].push_back(i+1); } rep(i,26)v[i].push_back(n+1); ll x = n * (n + 1) / 2; ll y = n * (n + 1) / 2; rep(i,26){ rep(j,v[i].size() - 1){ x -= (v[i][j+1] - v[i][j] - 1) * (v[i][j+1] - v[i][j]) / 2; } } double ans = (double)x / y; cout << fixed << setprecision(10) << ans << endl; return 0; }