#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();
  double ans = 0.0;
  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]++;
    }
  }
  for (int i = 'a'; i <= 'z'; ++i) {
    if (!good[i - 'a']) {
      continue;
    }
    int mn = 1000000;
    int cnt = 0;
    for (int dist = 1; dist < len; ++dist) {
      int cnt_tmp = 1;
      int mn_tmp = 1000000;
      for (int j = 'a'; j <= 'z'; ++j) {
        if (dp[i - 'a'][j - 'a'][dist]) {
          if (dp[i - 'a'][j - 'a'][dist] == mn_tmp) {
            ++cnt_tmp;
          }
          if (dp[i - 'a'][j - 'a'][dist] < mn_tmp) {
            mn_tmp = dp[i - 'a'][j - 'a'][dist];
            cnt_tmp = 1;
          }
        }
      }
      if (mn_tmp == 1) {
        cnt = max(cnt, cnt_tmp);
        mn = min(mn, mn_tmp);
      }
    }
    if (mn == 1) {
      ans += 1.0 * cnt / len;
    }
  }
  cout << setprecision(9) << ans;
}
