import java.io.*; import java.util.*; public class Main { static int n; public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); char[] values = sc.next().toCharArray(); int length = values.length; ArrayList> alpha = new ArrayList<>(); for (int i = 0; i < 26; i++) { alpha.add(new TreeSet<>()); alpha.get(i).add(length + 1); } for (int i = 0; i < length; i++) { alpha.get(values[i] - 'a').add(i + 1); } long count = 0; long base = (long)length * (length + 1) / 2; for (TreeSet set : alpha) { int prev = 0; long tmp = 0; for (int x : set) { tmp += (long)(x - prev - 1) * (x - prev) / 2; prev = x; } count += base - tmp; } System.out.println((double)count / base); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public String nextLine() throws Exception { return br.readLine(); } public String next() throws Exception { if (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }