#include using namespace std; using lint = long long; template using V = vector; template using VV = V< V >; struct DisjointSparseTable { using T = int; static T op(const T& x, const T& y) { return x | y; } const int n; VV t; template DisjointSparseTable(Itr first, Itr last) : n(distance(first, last)), t(__lg(n) + 1, V(first, last)) { for (int k = 1; k < (int) t.size(); ++k) { for (int i0 = 1 << k; i0 < n; i0 += 1 << k + 1) { for (int i = i0 + 1; i < min(i0 + (1 << k), n); ++i) { t[k][i] = op(t[k][i - 1], t[k][i]); } for (int i = i0 - 2; i >= i0 - (1 << k); --i) { t[k][i] = op(t[k][i], t[k][i + 1]); } } } } T acc(int l, int r) const { assert(l < r); if (l == --r) return t[0][l]; int k = __lg(l ^ r); return op(t[k][l], t[k][r]); } }; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); string s; cin >> s; int n = s.size(); V<> a(n); for (int i = 0; i < n; ++i) { a[i] = 1 << s[i] - 'a'; } DisjointSparseTable dst(begin(a), end(a)); VV<> b(n, V<>(27)); for (int k = 1; k <= 26; ++k) { int r = 0; for (int l = 0; l < n; ++l) { while (r < n and __builtin_popcount(dst.acc(l, r + 1)) <= k) ++r; b[l][k] = r; } } lint sum = 0; for (int l = 0; l < n; ++l) { b[l][0] = l; for (int k = 1; k <= 26; ++k) { sum += (b[l][k] - b[l][k - 1]) * k; } } cout << fixed << setprecision(15) << sum / (0.5 * n * (n + 1)) << '\n'; }