Problem: Vasya and Kolya play a game with a string, using the following rules. Initially, Kolya creates a string s, consisting of small English letters, and uniformly at random chooses an integer k from a segment [0, len(s) - 1]. He tells Vasya this string s, and then shifts it k letters to the left, i. e. creates a new string t = sk + 1sk + 2... sns1s2... sk. Vasya does not know the integer k nor the string t, but he wants to guess the integer k. To do this, he asks Kolya to tell him the first letter of the new string, and then, after he sees it, open one more letter on some position, which Vasya can choose.

Vasya understands, that he can't guarantee that he will win, but he wants to know the probability of winning, if he plays optimally. He wants you to compute this probability. 

Note that Vasya wants to know the value of k uniquely, it means, that if there are at least two cyclic shifts of s that fit the information Vasya knowns, Vasya loses. Of course, at any moment of the game Vasya wants to maximize the probability of his win.

Input

The only string contains the string s of length l (3 ≤ l ≤ 5000), consisting of small English letters only.

Output

Print the only number — the answer for the problem. You answer is considered correct, if its absolute or relative error does not exceed 10 - 6.

Formally, let your answer be a, and the jury's answer be b. Your answer is considered correct if <image>

Examples

Input

technocup


Output

1.000000000000000


Input

tictictactac


Output

0.333333333333333


Input

bbaabaabbb


Output

0.100000000000000

Note

In the first example Vasya can always open the second letter after opening the first letter, and the cyclic shift is always determined uniquely.

In the second example if the first opened letter of t is "t" or "c", then Vasya can't guess the shift by opening only one other letter. On the other hand, if the first letter is "i" or "a", then he can open the fourth letter and determine the shift uniquely.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
unsigned long long mod = 1e9 + 7;
unsigned long long ncr(long long int n, long long int k) {
  unsigned long long res = 1;
  if (k > n - k) k = n - k;
  for (int i = 0; i < k; ++i) {
    res *= (n - i);
    res /= (i + 1);
    res = res;
  }
  return res;
}
bool prime(unsigned long long num) {
  bool flag = true;
  for (unsigned long long i = 2; i * i <= num; i++) {
    if (num % i == 0) {
      flag = false;
      break;
    }
  }
  return flag;
}
long long ipow(long long base, long long exp) {
  long long result = 1;
  for (;;) {
    if (exp & 1) {
      result *= base;
      result = result % mod;
    }
    exp >>= 1;
    if (!exp) break;
    base *= base;
    base = base % mod;
  }
  return result % mod;
}
long long abs(long long a, long long b) {
  if ((a - b) > 0)
    return (a - b);
  else
    return (b - a);
}
long long MOD = 998244353;
long long add(long long a, long long b) {
  a += b;
  if (a >= MOD) a -= MOD;
  if (a < 0) a += MOD;
  return a;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long der(int k) {
  long long res = 0;
  long long fact = 1;
  for (int i = 2; i <= k; i++) fact *= i;
  int s = 1;
  long long j = 1;
  for (int i = 2; i <= k; i++) {
    j = j * i;
    long long first = (fact / j) * s;
    res += first;
    s = s * -1;
  }
  return res;
}
bool srt(long long &a, long long &b) { return a < b; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin >> s;
  int len = s.length();
  vector<int> a[26];
  for (long long i = 0; i < len; i++) {
    char c = s[i];
    a[c - 'a'].push_back(i);
  }
  set<int> unq1;
  map<pair<int, char>, int> mp1;
  map<char, pair<int, int>> mp;
  for (long long i = 0; i < 26; i++) {
    vector<int> k = a[i];
    int sz = k.size();
    if (sz == 0) continue;
    int nj = -1, mx = 0;
    map<char, pair<int, int>> tmp;
    for (int j = 1; j < len; j++) {
      int mx1 = 0;
      for (int x = 0; x < sz; x++) {
        char c = s[(k[x] + j) % len];
        tmp[c].first++;
        tmp[c].second = k[x];
      }
      for (char x = 'a'; x <= 'z'; x++) {
        if (tmp[x].first == 1) mx1++;
      }
      if (mx1 > mx) {
        nj = j;
        mx = mx1;
        mp = tmp;
      }
      tmp.clear();
      if (mx == sz) break;
    }
    for (char x = 'a'; x <= 'z' && nj != -1; x++) {
      if (mp[x].first == 1) {
        char c = s[(mp[x].second + nj) % len];
        if (mp1[{i, c}] == 0) {
          mp1[{i, c}] = 1;
          unq1.insert(mp[x].second);
        }
      }
    }
    mp.clear();
  }
  double out = unq1.size();
  double p = out / len;
  cout << fixed << setprecision(19) << p << endl;
}