#include using namespace std; using ll = long long; 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]]; } int& tar = nex[s[i] - 'a']; if (tar == -1) dp[i]++; tar = i; } ll res = 0; for (int i = 0; i < 26; i++) { if (nex[i] != -1) res += dp[nex[i]]; } return res; } int main() { cin.tie(0); ios::sync_with_stdio(false); string s; cin >> s; ll n = s.size(); ll val1 = 0; for (int i = 0; i < 26; i++) { val1 += calc(s, 'a' + i); } ll val2 = n * (n + 1) / 2;//calc2(s); //cerr << val2 << endl; cout << fixed << setprecision(15) << (long double)val1 / val2 << endl; return 0; }