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