#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;



char str[1000005];
int main(int argc, char* argv[])
{
    scanf("%s", str);

    map<char,int> z;
    map<char,double> val;
    int len=strlen(str);
    int i;
    for(i=0; i<len; i++) {
        auto it = z.find(str[i]);
        int tmp=0;
        if(it!=z.end()) {
            tmp=it->second+1;
        }
        if(i-tmp>0) {
            val[str[i]] += (double)(i-tmp)*(i-tmp+1)/2;
        }
        z[str[i]]=i;
    }

    double ans=0;
    auto it=z.begin();
    for(; it!=z.end(); ++it) {
        int tmp=it->second+1;
        if(len-tmp>0) {
            val[it->first] += (double)(len-tmp)*(len-tmp+1)/2;
        }
        ans += ((double)len*(len+1)/2-val[it->first]);
    }
    printf("%.10lf\n", ans / ((double)len*(len+1)/2) );

    return 0;
}