#include <bits/stdc++.h>
using namespace std;
int mat[30][30][5005], ans[30][5005];
void cycle(char s[], int n) {
  char aux = s[n - 1];
  for (int i = n - 1; i > 0; i--) s[i] = s[i - 1];
  s[0] = aux;
}
void inser(char *s, int n) {
  int i = s[0] - 'a', q, j;
  for (q = 1; q < n; q++) {
    j = s[q] - 'a';
    mat[i][j][q]++;
  }
}
bool check(char *s, int n) {
  int i = s[0] - 'a', q, j;
  for (q = 1; q < n; q++) {
    j = s[q] - 'a';
    if (mat[i][j][q] == 1) {
      ans[i][q]++;
    }
  }
  return false;
}
char s[5005];
int main() {
  int i, n, nr, act, j;
  double anss;
  cin >> s;
  n = strlen(s);
  for (i = 0; i < n; i++) {
    inser(s, n);
    cycle(s, n);
  }
  nr = 0;
  for (i = 0; i < n; i++) {
    check(s, n);
    cycle(s, n);
  }
  for (i = 0; i < 26; i++) {
    act = 0;
    for (j = 0; j < n; j++) act = max(act, ans[i][j]);
    nr += act;
  }
  anss = (double(nr) / (n));
  cout << fixed << setprecision(10);
  cout << anss << '\n';
  return 0;
}
