#define _USE_MATH_DEFINES #include using namespace std; signed main() { ios::sync_with_stdio(false); cin.tie(0); string s; cin >> s; vector pre(26, -1); long long tot = 0; int n = (int) s.size(); for (int i = 0; i < n; i++) { tot += 1LL * (i - pre[s[i] - 'a']) * (n - i); pre[s[i] - 'a'] = i; } cout << setprecision(20) << fixed << 1.0 * tot / (n * (n + 1) / 2) << endl; return 0; }