#include <bits/stdc++.h>
using namespace std;
char s[5010];
double max(double x, double y) { return x > y ? x : y; }
int f[30][5010][30];
int main(int argc, char const *argv[]) {
  scanf("%s", s);
  int n = strlen(s);
  for (int i = 0; i <= n - 1; ++i) {
    for (int j = 1; j <= n - 1; ++j) f[s[i] - 'a'][j][(s[(i + j) % n] - 'a')]++;
  }
  double ans = 0, x, maxx;
  for (int i = 0; i <= 25; ++i) {
    maxx = 0;
    for (int j = 1; j <= n - 1; ++j) {
      x = 0;
      for (int k = 0; k <= 25; ++k) {
        if (f[i][j][k] == 1) x += (double)(1.0) / (double)(n);
      }
      maxx = max(x, maxx);
    }
    ans += maxx;
  }
  printf("%.7lf\n", ans);
  return 0;
}
