using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; class TEST{ static void Main(){ Sol mySol =new Sol(); mySol.Solve(); } } class Sol{ public void Solve(){ N = S.Length; double ret = 0; for(int i=1;i<=26;i++){ ret += calc(i); } Console.WriteLine(ret); } double calc(int len){ var dl = new int[256]; int l = 0, lcnt = 0; var dr = new int[256]; int r = 0, rcnt = 0; double cnt = 0; for(int i=0;i 0){ dl[S[l]]++; l++; continue; } if(lcnt < len - 1){ dl[S[l]] = 1; l++; lcnt++; continue; } break; } while(r < N){ if(dr[S[r]] > 0){ dr[S[r]]++; r++; continue; } if(rcnt < len){ dr[S[r]] = 1; r++; rcnt++; continue; } break; } if(rcnt == len){ cnt += r - l; } if(dl[S[i]] > 0){ dl[S[i]]--; if(dl[S[i]] == 0) lcnt--; } if(dr[S[i]] > 0){ dr[S[i]]--; if(dr[S[i]] == 0) rcnt--; } } //Console.WriteLine("len:{0}, cnt:{1}",len, cnt); double tot = (double) N * (double) (N + 1) / 2.0; return (double) len * cnt / tot; } int N; String S; public Sol(){ S = rs(); } static String rs(){return Console.ReadLine();} static int ri(){return int.Parse(Console.ReadLine());} static long rl(){return long.Parse(Console.ReadLine());} static double rd(){return double.Parse(Console.ReadLine());} static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);} static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));} static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));} static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));} }