fabbbhgedd
 abbbaababbbaababbbaababbbaababbbaababbbaababbbaababbbaababbbaababbbaababbbaababbbaababbbaab
 hcdhgcchbdhbeagdcfedgcbaffebgcbcccadeefacbhefgeadfgchabgeebegahfgegahbddedfhffeadcedadgfbeebhgfahhfb
 khjcoijiicdkdianmdolmadobdkcmgifdnffddnjehhbldlkjffknficdcmokfacioiegjedbmadjioomdacbodcajcmonmnlabo
 bababbdaee
 cbbbbcaaca
 gaejllebhn
 eaaebccaeacdecaedcaabbbdeebccdcdaabeeaeeaddbaabdccebecebbbbedbdcbbbbbbecbaddcddcccdcbbadbecddecedbba
 difhjdjbcdjedhiegagdejkbjfcdcdagdijdjajecbheiabfbjdgjdecfhdkgdbkcgcgakkiiggfkgcfadkjhiijkjacgejfhjge
 bbababaaababaabbbbbabbbbbbaaabbabaaaaabbbbbaaaabbbbabaabaabababbbabbabbabaaababbabbababaaaaabaaaabbb
 cadbcdddda
 kpsaloedscghjeaqadfhmlibjepjafdomkkorinrpakondtnrnknbqarbejcenrlsbfgdbsdmkpphbkdnbitjfcofsjibssmmlll
 aaabbbaaaabbbbaaabbbbbaabbbbaaababbaaabbbbaaabbbbababbbbaaabbbbaaabbbbbaabbbbaaabbbbaaabbbb
 ibledofnibedebifmnjdoaijeghajecbkjaebbkofnacceaodiifbhgkihkibddneeiemacodeafeaiiiaoajhmkjffbmmiehebhokfklhbkeoanoajdedjdlkbhenidclagggfhhhldfleccgmjbkhaginlhabkabagikalccndciokabfaebjkndf
 abbacba
 jkeaagakbifeaechkifkdghcjcgighidcgdccfbdbcackfgaebkddabgijkhjkaffkabacekdkjekeccegbecbkecbgbgcacgdackcdfjefaifgbigahkbedidfhjbikejdhejcgideaeejdcegeeccaefbddejkbdkfagfcdjbikbidfggkidcdcic

1.000000000000000
 0.000000000000000
 0.450000000000000
 0.960000000000000
 1.000000000000000
 0.800000000000000
 1.000000000000000
 0.080000000000000
 0.840000000000000
 0.000000000000000
 0.800000000000000
 1.000000000000000
 0.000000000000000
 0.786096256684492
 1.000000000000000
 0.438502673796791

#include <bits/stdc++.h>
int cant[26][5010];
int ccnt[26];
int rcnt[26][5010];
short cnt[26][5010][676];
char o[5010];
bool imp[26][5010];
bool use[26];
int main() {
  int n;
  scanf("%s", o);
  n = (int)strlen(o);
  double prob = 0.0;
  for (int i = 0; i < n; i++) {
    o[i] -= 'a';
    ccnt[o[i]]++;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 1; j < n; j++) {
      int tmp = (i + j) % n;
      auto &v = cnt[o[i]][j][(int)o[i] * 26 + o[tmp]];
      if (v > 0) imp[o[i]][j] = true;
      v++;
    }
  }
  for (int i = 0; i < 26; i++) {
    int flag = 1;
    for (int j = 1; j < n; j++)
      if (!imp[i][j]) flag = 0;
    if (!flag) {
      prob += (double)ccnt[i] / n;
      use[i] = true;
    }
  }
  for (int i = 0; i < n; i++) {
    if (use[o[i]]) continue;
    for (int j = 1; j < n; j++) {
      int tmp = (i + j) % n;
      auto &v = cnt[o[i]][j][(int)o[i] * 26 + o[tmp]];
      if (v == 1) {
        rcnt[o[i]][j]++;
      }
    }
  }
  for (int i = 0; i < 26; i++) {
    if (use[i]) continue;
    int upp = 0;
    for (int j = 1; j < n; j++)
      if (upp < rcnt[i][j]) upp = rcnt[i][j];
    if (upp != 0) prob += (double)upp / n;
  }
  printf("%.10lf\n", prob);
  return 0;
}
