#include <bits/stdc++.h>
using namespace std;
const int nmax = 5004;
int n;
int may[nmax];
char ch[nmax];
vector<int> pos[nmax];
int main() {
  scanf("%s", ch);
  n = strlen(ch);
  int posib = 0;
  int ttt = 0;
  double st = 0;
  for (int i = 0; i < n; i++) pos[ch[i]].push_back(i);
  for (int i = 'a'; i <= 'z'; i++) {
    if (pos[i].size() == 0) continue;
    int maxim = 0;
    for (int j = 1; j < n; j++) {
      int stt = pos[i].size();
      ++ttt;
      for (vector<int>::iterator it = pos[i].begin(); it != pos[i].end();
           ++it) {
        int p2 = (*it) + j;
        if (p2 >= n) p2 -= n;
        may[ch[p2]]++;
      }
      for (vector<int>::iterator it = pos[i].begin(); it != pos[i].end();
           ++it) {
        int p2 = (*it) + j;
        if (p2 >= n) p2 -= n;
        if (may[ch[p2]] != 1) stt -= (may[ch[p2]]);
        may[ch[p2]] = 0;
      }
      maxim = max(maxim, stt);
    }
    st += maxim;
  }
  st /= n;
  cout << setprecision(7) << st;
}
