#include <bits/stdc++.h>
using namespace std;
int n;
string s;
int ways[26][5013][26];
int occurrence[26];
int main() {
  if (fopen("FILENAME.in", "r")) {
    freopen("FILENAME.in", "r", stdin);
    freopen("FILENAME.out", "w", stdout);
  }
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> s;
  n = s.size();
  for (int i = 0; i < n; i++) {
    char first = s[0];
    for (int j = 1; j < n; j++) {
      char second = s[j];
      ways[first - 'a'][j][second - 'a']++;
    }
    occurrence[first - 'a']++;
    s = s.substr(1, n - 1) + s.substr(0, 1);
  }
  double weighted = 0;
  for (int i = 0; i < 26; i++) {
    int sum = 0;
    double bestValue = 0;
    int bestIndex = -1;
    for (int j = 1; j < n; j++) {
      int total = 0;
      int good = 0;
      for (int k = 0; k < 26; k++) {
        if (ways[i][j][k] == 1) {
          good++;
        }
        total += ways[i][j][k];
      }
      double value = ((double)good) / total;
      if (value > bestValue) {
        bestValue = value;
        bestIndex = j;
      }
    }
    weighted += bestValue * occurrence[i];
  }
  cout << setprecision(10) << weighted / n << endl;
}
