#include <bits/stdc++.h>
using namespace std;
const int maxn = 5005;
const int maxm = maxn * 2;
const int maxe = 200005;
const int mod = 1e9 + 7;
int n, a, b;
string str;
int cc[26][maxn][26];
int exist[26];
int main() {
  cin >> str;
  n = str.length();
  for (int i = 0; i < n; i++) {
    int idx = str[i] - 'a';
    exist[idx]++;
    for (int j = 1; j < n; j++) {
      int pos = (i + j) % n;
      int idx2 = str[pos] - 'a';
      cc[idx][j][idx2]++;
    }
  }
  double ans = 0;
  for (int i = 0; i < 26; i++) {
    double cccc = 0;
    for (int j = 1; j < n; j++) {
      double tp = 0;
      for (int ii = 0; ii <= n; ii++) {
        if (str[ii] - 'a' != i) continue;
        int pos = (ii + j) % n;
        int idx2 = str[pos] - 'a';
        if (cc[i][j][idx2] == 1) tp++;
      }
      cccc = max(cccc, tp);
    }
    ans += cccc;
  }
  printf("%.15lf\n", ans / n);
  return 0;
}
