#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 3;
const int inf = 1e9 + 3;
const int md = 1e9 + 7;
int n, m;
string s;
string g[5001];
int ps[26][26][5001];
int kk[26];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed;
  cout << setprecision(10);
  cin >> s;
  n = s.size();
  for (int i = 0; i < n; ++i) {
    g[i] = s;
    char k = s[s.size() - 1];
    s.erase(s.begin() + s.size() - 1);
    s = k + s;
  }
  long double res = 0;
  for (int i = 0; i < n; ++i) {
    s = g[i];
    int p1 = s[0] - 'a';
    kk[p1]++;
    int p2;
    for (int j = 0; j < n; ++j) {
      p2 = s[j] - 'a';
      ps[p1][p2][j]++;
    }
  }
  for (int i = 0; i < 26; ++i) {
    if (kk[i] == 0) continue;
    long double mx = 0;
    for (int j = 0; j < n; ++j) {
      long double sm = 0;
      for (int k = 0; k < 26; ++k) {
        if (ps[i][k][j] != 1) continue;
        sm += ((long double)kk[i] / n) * ((long double)1 / (long double)kk[i]);
      }
      mx = max(mx, sm);
    }
    res += mx;
  }
  cout << res;
}
