#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &x) {
  char c;
  bool nega = 0;
  while ((!isdigit(c = getchar())) && (c != '-'))
    ;
  if (c == '-') {
    nega = 1;
    c = getchar();
  }
  x = c - 48;
  while (isdigit(c = getchar())) x = x * 10 + c - 48;
  if (nega) x = -x;
}
template <typename T>
inline void writep(T x) {
  if (x > 9) writep(x / 10);
  putchar(x % 10 + 48);
}
template <typename T>
inline void write(T x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  writep(x);
}
template <typename T>
inline void writeln(T x) {
  write(x);
  putchar('\n');
}
int n;
int F[5005][28][28];
int dem[5005][28];
string s;
char c[2 * 5005 + 5];
void enter() {
  cin >> s;
  n = s.size();
  for (int i = 0; i < n; i++) c[i] = s[i];
}
inline bool satisfy(int x, int y) {
  return F[y][c[x] - 'a'][c[x + y] - 'a'] == 1;
}
void progress() {
  for (int i = 0; i < n; i++) c[i + n] = c[i];
  for (int i = 0; i < n; i++) {
    for (int j = 1; j < n; j++) {
      F[j][c[i] - 'a'][c[i + j] - 'a']++;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 1; j < n; j++) {
      if (satisfy(i, j)) {
        dem[j][c[i] - 'a']++;
      }
    }
  }
  int res = 0;
  for (int i = 0; i < 26; i++) {
    int optimal = -1;
    for (int j = 1; j < n; j++) {
      optimal = max(optimal, dem[j][i]);
    }
    res += optimal;
  }
  printf("%.8lf\n", res * 1.0 / n);
}
int main() {
  enter();
  progress();
}
