#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 5;
vector<int> ans[300];
vector<char> v[130][5005];
int ct[30][5005][130];
double solve(string &s) {
  int win = 0, n = s.size();
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      v[s[i]][j].push_back(s[(i + j) % n]);
      ct[s[i] - 'a'][j][s[(i + j) % n]]++;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      char c = s[(i + j) % n];
      if (ct[s[i] - 'a'][j][c] == 1) ans[s[i]].push_back(j);
    }
  }
  for (int i = 'a'; i <= 'z'; i++) {
    if (ans[i].empty()) continue;
    sort(ans[i].begin(), ans[i].end());
    int cnt = 1, maxi = 0;
    for (int j = 1; j < ans[i].size(); j++) {
      if (ans[i][j] != ans[i][j - 1]) {
        maxi = max(maxi, cnt);
        cnt = 1;
      } else
        cnt++;
    }
    maxi = max(maxi, cnt);
    win += maxi;
  }
  return (double)win / s.size();
}
int main() {
  ios::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  string s;
  cin >> s;
  cout << fixed << setprecision(10) << solve(s);
}
