#[macro_export] macro_rules! setup { { mut $input:ident: SplitWhitespace $(,)? } => { use std::io::Read; let mut buf = String::new(); std::io::stdin().read_to_string(&mut buf).ok(); let mut $input = buf.split_whitespace(); }; } #[macro_export] macro_rules! parse_next { ($str_iter:expr) => { $str_iter.next().unwrap().parse().ok().unwrap() }; } #[allow(unused_imports)] use std::collections::{HashMap, HashSet, VecDeque}; fn main() { setup! { mut input: SplitWhitespace }; let s: String = parse_next!(input); const MOD: u64 = 573; let mut cs = HashMap::new(); s.chars().for_each(|c| { *cs.entry(c).or_insert(0 as usize) += 1; }); let mut comb = vec![vec![0; s.len() + 1]; s.len() + 1]; for i in 0..=s.len() { for j in 0..=i { if j == 0 || j == i { comb[i][j] = 1; } else { let left = comb[i - 1][j - 1]; let right = comb[i - 1][j]; comb[i][j] = (left + right) % MOD; } } } let ans = (|| { let mut ret = 1; let mut len = s.len(); for count in cs.values() { ret = (ret * comb[len][*count]) % MOD; len -= *count; } (ret + MOD - 1) % MOD })(); println!("{}", ans); }