#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie();
  string s;
  cin >> s;
  int n = s.size();
  int *a = new int[n];
  for (int i = 0; i < n; i++) a[i] = s[i] - 'a';
  vector<int> *mat[26];
  for (int i = 0; i < 26; i++) {
    mat[i] = new vector<int>[n];
    for (int j = 0; j < n; j++) mat[i][j] = vector<int>(26, 0);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      int pos = (i + j) % n;
      mat[a[i]][j][a[pos]]++;
    }
  }
  int *ones[26];
  int ans[26];
  for (int i = 0; i < 26; i++) {
    ones[i] = new int[n];
    int best = 0;
    for (int j = 0; j < n; j++) {
      ones[i][j] = 0;
      for (auto k : mat[i][j]) {
        if (k == 1) ones[i][j]++;
      }
      if (ones[i][best] < ones[i][j]) best = j;
    }
    ans[i] = best;
  }
  int wins = 0;
  for (int i = 0; i < n; i++) {
    int pos = (i + ans[a[i]]) % n;
    int buk = a[i];
    if (mat[buk][ans[buk]][a[pos]] == 1) wins++;
  }
  double res = (wins * 1.0) / n;
  cout.precision(14);
  cout << fixed << res;
  return 0;
}
int __test() {
  clock_t t = clock();
  main();
  cout << '\n';
  cout << "TIME\t" << (clock() - t);
  return 0;
}
