#include <bits/stdc++.h>
using namespace std;
vector<int> occ[27];
int mem[27][5001][27], p[27][5001];
int main() {
  string second;
  cin >> second;
  int n = second.size();
  for (int i = 0; i < n; i++) occ[second[i] - 'a'].push_back(i);
  double ans = 0;
  for (int i = 0; i < 27; i++) {
    for (int j : occ[i]) {
      for (int k = j + 1; k < (j + n); k++)
        mem[i][(k - j)][second[(k % n)] - 'a']++;
    }
    for (int j : occ[i]) {
      for (int k = 1; k < n; k++) {
        if (mem[i][k][second[(k + j) % n] - 'a'] == 1) p[i][k]++;
      }
    }
    if (occ[i].size() != 0) ans += *max_element(p[i], p[i] + 5001);
  }
  cout << fixed << setprecision(9) << ans / double(n) << endl;
}
