Scanf.scanf "%s" (fun a ->
    let n = String.length a in
    let hist = Array.make 26 0 in
    String.iter (fun c ->
        let q = int_of_char c - 97 in
        hist.(q) <- hist.(q) + 1) a;
    let ans = Array.fold_left (fun acc v -> acc - v * (v - 1)) (n * (n - 1)) hist in
    Printf.printf "%d\n" @@ ans / 2 + 1
)