#include #include #include #include using namespace std; // 575 int main() { string S; cin >> S; set alpha[26]; int64_t sum = 0; for (int i = 0;i < 26;++ i) alpha[i].insert(S.size()); for (int i = 0;i < S.size();++ i) alpha[S[i] - 'a'].insert(i); for (int i = 0;i < S.size();++ i) sum += (*alpha[S[i] - 'a'].upper_bound(i) - i) * (i + 1); cout << setprecision(3) << fixed << sum * 2.0 / S.size() / (S.size() + 1) << endl; return 0; }