#include <bits/stdc++.h>
using namespace std;
int cnt[30][30], n, sum[30], ok[30][5010];
char s[5010], a[5010][5010];
int main() {
  scanf("%s", s);
  n = strlen(s);
  for (int i = 0; i < n; i++) {
    int tmp = s[i] - 'a' + 1;
    sum[tmp]++;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 1; j < n; j++) {
      int pos = (i + j) % n;
      a[i][j] = s[pos];
    }
  }
  for (int i = 1; i < n; i++) {
    memset(cnt, 0, sizeof(cnt));
    for (int j = 0; j < n; j++) {
      int tmp2 = a[j][i] - 'a' + 1;
      int tmp1 = s[j] - 'a' + 1;
      cnt[tmp1][tmp2]++;
    }
    for (int j = 0; j < n; j++) {
      int tmp2 = a[j][i] - 'a' + 1;
      int tmp1 = s[j] - 'a' + 1;
      if (cnt[tmp1][tmp2] > 1) a[j][i] = '.';
    }
  }
  double ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 1; j < n; j++) {
      if (a[i][j] != '.') {
        int tmp = s[i] - 'a' + 1;
        ok[tmp][j]++;
      }
    }
  }
  for (int i = 1; i <= 26; i++) {
    int mx = 0;
    for (int j = 1; j < n; j++) {
      mx = max(mx, ok[i][j]);
    }
    ans += mx;
  }
  ans = ans / (double)n;
  printf("%.15f", ans);
  return 0;
}
