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>
using namespace std;
int main() {
  cout.precision(16);
  string temp;
  getline(cin, temp);
  int n = temp.size();
  string string_opt[5010];
  string_opt[0] = temp;
  for (int i = 1; i < n; i++) {
    string t;
    for (int j = 1; j < (n + 1); j++) {
      t.push_back(string_opt[i - 1].at(j % n));
    }
    string_opt[i] = t;
  }
  sort(string_opt, string_opt + n);
  char last_char = string_opt[n - 1].at(0);
  int total = 0;
  int a = 0;
  int b = 1;
  while (a < n) {
    if ((string_opt[a].at(0) == last_char) ||
        string_opt[b].at(0) != string_opt[b - 1].at(0)) {
      if (string_opt[a].at(0) == last_char) {
        b = n;
      }
      if (b - a > 1) {
        int max_variation = -1;
        for (int k = 1; k < n; k++) {
          vector<char> chars;
          for (int j = a; j < b; j++) {
            chars.push_back(string_opt[j].at(k));
          }
          sort(chars.begin(), chars.end());
          int tot = 0;
          if (chars[0] != chars[1]) tot++;
          if (chars[chars.size() - 1] != chars[chars.size() - 2]) tot++;
          for (int j = 1; j < chars.size() - 1; j++) {
            if (chars[j] != chars[j - 1] && chars[j] != chars[j + 1]) tot++;
          }
          max_variation = max(max_variation, tot);
          if (max_variation == (b - a)) break;
        }
        total += max_variation;
      } else {
        total++;
      }
      a = b;
    }
    b++;
  }
  double ans = ((double)total) / ((double)n);
  cout << ans << endl;
  return 0;
}
