#include <bits/stdc++.h>
using namespace std;
template <class t>
inline t read(t &x) {
  char c = getchar();
  bool f = 0;
  x = 0;
  while (!isdigit(c)) f |= c == '-', c = getchar();
  while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
  if (f) x = -x;
  return x;
}
template <class t>
inline void write(t x) {
  if (x < 0)
    putchar('-'), write(-x);
  else {
    if (x > 9) write(x / 10);
    putchar('0' + x % 10);
  }
}
const int N = 5005;
string s;
int n, a[N][26][26], cnt[26][N], sz[26];
double ans;
signed main() {
  cin >> s;
  n = s.size();
  s = s + s;
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < i + n; j++) a[j - i][s[i] - 'a'][s[j] - 'a']++;
  for (int i = 0; i < n; i++) {
    for (int j = 1; j < n; j++)
      cnt[s[i] - 'a'][j] += a[j][s[i] - 'a'][s[i + j] - 'a'] == 1;
    sz[s[i] - 'a']++;
  }
  for (int i = 0; i < 26; i++)
    if (sz[i]) ans += 1.0 * (*max_element(cnt[i] + 1, cnt[i] + n)) / n;
  printf("%lf", ans);
}
