#include using namespace std; using ll = __int128; ll calc(string& s, char c) { ll n = s.size(); ll res = n * (n + 1) / 2; ll cur = 0; for (ll i = 0; i < n; i++) { if (s[i] == c) { ll d = i - cur; res -= d * (d + 1) / 2; cur = i + 1; } } ll d = n - cur; res -= d * (d + 1) / 2; return res; } ll calc2(string& s) { int n = s.size(); vector nex(26, -1); vector dp(n, 0); for (int i = n - 1; i >= 0; i--) { for (int j = 0; j < 26; j++) { if (nex[j] == -1) continue; dp[i] += dp[nex[j]]; } nex[s[i] - 'a'] = i; } ll res = 0; for (int i = 0; i < 26; i++) { res += dp[i]; } return res; } int main() { cin.tie(0); ios::sync_with_stdio(false); string s; cin >> s; int n = s.size(); ll val1 = 0; for (int i = 0; i < 26; i++) { val1 += calc(s, 'a' + i); } ll val2 = n * (n + 1) / 2; cout << fixed << setprecision(15) << (long double)val1 / val2 << endl; return 0; }