#include <bits/stdc++.h>
using namespace std;
const int maxn = 5050;
vector<int> pos[26];
int sum[maxn];
char s[maxn];
void solve() {
  scanf("%s", s);
  int len_s = strlen(s);
  for (int i = 0; i < len_s; i++) pos[s[i] - 'a'].push_back(i);
  double res = 0.0;
  for (int j = 0; j < 26; j++) {
    int ans = 0;
    for (int i = 1; i <= len_s - 1; i++) {
      int tmp = 0;
      for (auto x : pos[j]) {
        int id = (s[x] - 'a') * 26 + s[(x + i) % len_s] - 'a';
        sum[id]++;
        if (sum[id] == 1)
          tmp++;
        else if (sum[id] == 2)
          tmp--;
      }
      ans = max(ans, tmp);
      for (auto x : pos[j]) {
        int id = (s[x] - 'a') * 26 + s[(x + i) % len_s] - 'a';
        sum[id]--;
      }
    }
    res += (double)ans / len_s;
  }
  printf("%.15f\n", res);
}
int main() {
  solve();
  return 0;
}
