#include <bits/stdc++.h>
template <typename T>
inline void ckmax(T& x, T y) {
  x = (y > x ? y : x);
}
template <typename T>
inline void ckmin(T& x, T y) {
  x = (y < x ? y : x);
}
using namespace std;
const int inf = 0x7f7f7f7f;
const int INF = 0x7f7f7f3f;
const int mod = 998244353;
const long double eps = 1e-8;
inline int fpow(int a, int b) {
  int res = 1;
  while (b) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return res;
}
int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = (x << 3) + (x << 1) + (c ^ 48);
    c = getchar();
  }
  return x * f;
}
const int N = 5050;
vector<int> pos[N];
string s;
int n, a[N << 1];
double res, cnt[N];
inline int calc(int x, int ps) {
  std::vector<int> tmp(N);
  for (int qwq : pos[x]) {
    tmp[a[qwq + ps]]++;
  }
  int tot = 0;
  for (int i = (0), iE = (26); i < iE; i++) tot += (tmp[i] == 1);
  return tot;
}
inline void solve(int x) {
  int mx = 0;
  for (int i = (1), iE = (n); i < iE; i++) mx = max(mx, calc(x, i));
  res += (double)((double)(1.0 * mx) / ((double)pos[x].size() * 1.0)) * cnt[x];
}
signed main() {
  cin >> s;
  n = s.size();
  for (int i = (0), iE = (n); i < iE; i++) a[i] = s[i] - 'a';
  for (int i = (0), iE = (n); i < iE; i++)
    pos[a[i]].push_back(i), cnt[a[i]] += (double)1.0;
  for (int i = (0), iE = (26); i < iE; i++) cnt[i] /= (double)(1.0 * n);
  for (int i = (n), iE = (2 * n); i < iE; i++) a[i] = a[i - n];
  for (int i = (0), iE = (26); i < iE; i++)
    if (cnt[i] > (double)0.0) solve(i);
  printf("%.8f\n", res);
}
