#include <bits/stdc++.h>
using namespace std;
char s[5005], a[5005][5005];
int chk[30][5005];
vector<int> v[30];
int main() {
  scanf("%s", s);
  int n = strlen(s);
  int c;
  for (int i = 0; i < n; i = i + 1) {
    v[s[i] - 'a'].push_back(i);
  }
  for (int i = 0; i < n; i = i + 1) {
    for (int j = 0; j < n; j = j + 1) {
      a[i][j] = s[(i + j) % n];
    }
    a[i][n] = '\0';
  }
  double sum = 0, mx, tmp;
  for (int i = 0; i < 26; i = i + 1) {
    if (v[i].size() == 0) continue;
    if (v[i].size() == 1) {
      sum += (1.0 / (1.0 * n));
      continue;
    }
    for (int j = 0; j < 26; j = j + 1) {
      for (int k = 0; k < n; k = k + 1) chk[j][k] = -1;
    }
    for (int j = 0; j < v[i].size(); j = j + 1) {
      c = v[i][j];
      for (int k = 1; k < n; k = k + 1) {
        if (chk[a[c][k] - 'a'][k] == -1)
          chk[a[c][k] - 'a'][k] = c;
        else if (chk[a[c][k] - 'a'][k] > -1)
          chk[a[c][k] - 'a'][k] = -2;
      }
    }
    mx = 0;
    for (int j = 1; j < n; j = j + 1) {
      tmp = 0;
      for (int k = 0; k < 26; k = k + 1) {
        if (chk[k][j] > -1) tmp++;
      }
      mx = max(tmp, mx);
    }
    sum += (mx / (1.0 * n));
  }
  printf("%.10lf\n", sum);
  return 0;
}
