#include <bits/stdc++.h>
#pragma comment(linker, "/stack:16777216")
using namespace std;
const int INF = 1000000000;
const int MAX = 5007;
const int MAX2 = 7000;
const int BASE = 1000000000;
int n;
string S;
int B[26][MAX][26];
int C[26][MAX];
int W[26];
int main() {
  cin >> S;
  n = (int)S.size();
  for (int i = (0); i < (n); ++i) {
    int a = S[i] - 'a';
    ++W[a];
    for (int j = (0); j < (n); ++j) {
      int p = i + j;
      while (p >= n) p -= n;
      int b = S[p] - 'a';
      if (B[a][j][b] == 0)
        ++C[a][j];
      else if (B[a][j][b] == 1)
        --C[a][j];
      ++B[a][j][b];
    }
  }
  double res = 0;
  for (int i = (0); i < (26); ++i) {
    if (W[i] == 0) continue;
    double p = 1.0 * W[i] / n;
    int mx = 0;
    for (int j = (0); j < (n); ++j) mx = max(mx, C[i][j]);
    res += p * mx / W[i];
  }
  printf("%0.11f\n", res);
  return 0;
}
