fn main() { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); let s = s.trim().chars().map(|c| c as usize - 'a' as usize).collect::>(); let n = s.len(); let total = n * (n + 1) / 2; let mut cnts = 0usize; for i in 0..26 { let mut indices = (0..n).filter(|&j| s[j] == i).map(|j| j as isize).collect::>(); indices.insert(0, -1); for j in 0..indices.len()-1 { let start = indices[j]+1; let end = indices[j+1]; cnts += (end-start+1) as usize * (n - end as usize); } } println!("{}", cnts as f64 / total as f64); }