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() {
  string s, ss;
  cin >> s;
  ss = s + s;
  int n = s.size();
  int* letters[26][26];
  int counter[26] = {};
  for (int i = 0; i < 26; ++i) {
    for (int j = 0; j < 26; ++j) {
      letters[i][j] = new int[n];
    }
  }
  for (int i = 0; i < n; ++i) {
    int c1 = s.at(i) - 'a';
    counter[c1] += 1;
    for (int j = 0; j < n; ++j) {
      int c2 = ss.at(j + i) - 'a';
      letters[c1][c2][j] += 1;
    }
  }
  vector<int> conflicts[26];
  vector<int> pair_counts[26];
  for (int i = 0; i < 26; ++i) {
    conflicts[i].resize(n);
    pair_counts[i].resize(n);
  }
  int count = 0;
  for (int i = 0; i < 26; ++i) {
    for (int j = 0; j < 26; ++j) {
      for (int k = 0; k < n; ++k) {
        int val = letters[i][j][k];
        if (val > 0) {
          pair_counts[i][k] += val;
          if (val > 1) {
            conflicts[i][k] += val;
          }
        }
      }
    }
  }
  for (int i = 0; i < 26; ++i) {
    if (counter[i]) {
      double max_noconflict = -1;
      for (int j = 0; j < n; ++j) {
        if (conflicts[i][j] == 0) {
          max_noconflict = 1;
          break;
        }
        max_noconflict = max(max_noconflict,
                             1.0 - double(conflicts[i][j]) / pair_counts[i][j]);
      }
      count += max_noconflict * counter[i];
    }
  }
  cout.precision(6);
  cout << fixed << double(count) / n << endl;
  for (int i = 0; i < 26; ++i) {
    for (int j = 0; j < 26; ++j) {
      delete[] letters[i][j];
    }
  }
  return 0;
}
