#include <bits/stdc++.h>
using namespace std;
string s;
vector<int> a[26];
int b[26][26][5005];
int c[26][26][5005];
int e[26][5005];
int d[26], f[26];
set<int> s1;
int main() {
  cin >> s;
  for (int i = 1; i <= s.length(); i++) {
    a[s[i - 1] - 'a'].push_back(i);
  }
  for (int i = 0; i < 26; i++) {
    for (int j = 0; j < 26; j++) {
      for (auto k : a[i])
        for (auto h : a[j]) {
          if (h == k) continue;
          if (k < h)
            b[i][j][h - k] = k, c[i][j][(h - k)]++;
          else
            b[i][j][h + s.length() - k] = k, c[i][j][(h + s.length() - k)]++;
        }
    }
  }
  int ans = 0;
  int n = s.length();
  for (int i = 0; i < 26; i++)
    for (int j = 0; j < 26; j++)
      for (int k = 1; k <= n; k++) {
        if (c[i][j][k] == 1) {
          s1.insert(b[i][j][k]);
          e[s[b[i][j][k] - 1] - 'a'][k]++;
          if (e[s[b[i][j][k] - 1] - 'a'][k] > d[s[b[i][j][k] - 1] - 'a'])
            d[s[b[i][j][k] - 1] - 'a'] = e[s[b[i][j][k] - 1] - 'a'][k];
        }
      }
  ans = s.size();
  for (auto h : s1) f[s[h - 1] - 'a']++;
  double an = 0;
  for (int i = 0; i < 26; i++) {
    if (d[i]) an = an + double(d[i]) / double(n);
  }
  cout << fixed << setprecision(10) << an << '\n';
  return 0;
}
