use std::io::*; use std::str::*; const MOD: i32 = 1000000007; fn read() -> Option { let stdin = stdin(); let s = stdin .bytes() .map(|c| c.unwrap() as char) .take_while(|c| !c.is_whitespace()) .collect::(); s.parse::().ok() } use std::collections::HashSet; fn dfs(a: String, b: &String, mut hs: &mut HashSet) { // println!("a:{} b:{}", a, b); if a.len() == 1 { let s = b.to_string() + &a; // println!("inserting .. {}", s); hs.insert(s); return; } let front = b.to_string() + &a[0..1].to_string(); let back = b.to_string() + &a[a.len() - 1..a.len()].to_string(); // println!("front : {}", front); // println!("back : {}", back); dfs(a[1..(a.len())].to_string(), &front, hs); dfs(a[0..(a.len() - 1)].to_string(), &back, hs); } fn main() { let mut hs: HashSet = HashSet::new(); let s: String = read().unwrap(); if s.len() == 1 { println!("1"); return; } if s.len() == 2 { if s.chars().nth(0) == s.chars().nth(1) { println!("1"); return; } println!("2"); return; } dfs(s, &"".to_string(), &mut hs); println!("{}", hs.len()); }