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 dp[30][30][5005];
int good[30];

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    string s;
    cin >> s;
    int len = s.length();
    for (int i = 0; i < len; ++i) {
        good[s[i] - 'a']++;
        int dist = 0;
        for (int j = i + 1; j < len; ++j) {
            ++dist;
            dp[s[i] - 'a'][s[j] - 'a'][dist]++;
        }
        for (int j = 0; j < i; ++j) {
            ++dist;
            dp[s[i] - 'a'][s[j] - 'a'][dist]++;
        }
    }
    int cnt = 0;
    for (int i = 0; i <= len; ++i) {
        bool ok = false;
        if (!good[s[i] - 'a']) {
            continue;
        }
        for (int dist = 0; dist < len; ++dist) {
            ok = true;
            bool been = false;
            for (int j = 'a'; j <= 'z'; ++j) {
                if (dp[s[i] - 'a'][j - 'a'][dist]) {
                    been = true;
                }
                if (dp[s[i] - 'a'][j - 'a'][dist] > 1) {
                    ok = false;
                }
            }
            if (ok && been) {
                break;
            }
        }
        if (ok) {
            ++cnt;
        }
    }
    double ans = cnt * 1.0 / len;
    if (!cnt) {
        cout << setprecision(9) << 1.0 / len;
    } else {
        cout << setprecision(9) << ans * 1.0;
    }
}
