#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  bool b = 1;
  for (int i = 0; i + 1 < (int)(s.size()); i++)
    if (s[i] != s[i + 1]) b = 0;
  string s2 = s + s;
  int* k[26][26];
  for (int i = 0; i < 26; i++)
    for (int j = 0; j < 26; j++) k[i][j] = new int[5000];
  for (int i = 0; i < 26; i++)
    for (int j = 0; j < 26; j++)
      for (int t = 0; t < 5000; t++) k[i][j][t] = 0;
  for (int i = 0; i < (int)s.size(); i++) {
    for (int j = 1; j < (int)s.size(); j++)
      k[s2[i] - 'a'][s2[i + j] - 'a'][j]++;
  }
  int* kk[26];
  for (int i = 0; i < 26; i++) kk[i] = new int[5000];
  for (int i = 0; i < 26; i++)
    for (int j = 0; j < 5000; j++) kk[i][j] = 0;
  for (int i = 0; i < 26; i++)
    for (int j = 0; j < 26; j++)
      for (int t = 0; t < 5000; t++)
        if (k[i][j][t] == 1) kk[i][t]++;
  long double ans = 0;
  for (int i = 0; i < (int)s.size(); i++) {
    int maxi = 0;
    for (int j = 1; j < (int)s.size(); j++)
      if (kk[s[i] - 'a'][j] > maxi) maxi = kk[s[i] - 'a'][j];
    ans += (double)(maxi) / (count(s.begin(), s.end(), s[i]));
  }
  ans /= ((int)s.size());
  cout << setprecision(12) << ans;
  return 0;
}
