import java.io.*; import java.util.*; import java.util.function.*; import java.util.stream.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); char[] inputs = sc.next().toCharArray(); List> positions = new ArrayList<>(); for (int i = 0; i < 26; i++) { positions.add(new TreeSet<>()); positions.get(i).add(-1); positions.get(i).add(inputs.length); } long ans = (inputs.length + 1L) * inputs.length / 2 * 26; double base = (inputs.length + 1L) * inputs.length / 2; for (int i = 0; i < inputs.length; i++) { positions.get(inputs[i] - 'a').add(i); } for (TreeSet current : positions) { Integer key = current.first(); while ((key = current.higher(key)) != null) { int size = key - current.lower(key) - 1; ans -= (size + 1L) * size / 2; } } System.out.println(ans / base); } } class Scanner { BufferedReader br; StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() { try { br = new BufferedReader(new InputStreamReader(System.in)); } catch (Exception e) { } } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public double nextDouble() { return Double.parseDouble(next()); } public String next() { try { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } } catch (Exception e) { e.printStackTrace(); } finally { return st.nextToken(); } } }