use std::collections::{HashSet, HashMap}; fn main() { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); let s = s.trim(); let mut cands = HashMap::new(); cands.insert(s.parse::().unwrap(), 1); for i in 1..1usize<<(s.len()-1) { let mut summary = 0usize; let target = (0..s.len()-1).filter(|&j| ((i >> j) & 1) == 1).collect::>(); for j in 0..=target.len() { summary += if j == 0 { s[0..=target[j]].parse::().unwrap() } else if j == target.len() { s[target[j-1]+1..].parse::().unwrap() } else { s[target[j-1]+1..=target[j]].parse::().unwrap() }; } *cands.entry(summary).or_insert(0usize) += 1; } let mut result = 0usize; for (&v, &cnt) in cands.iter() { if v == 1 { continue; } let mut flg = false; for i in 2..=(v as f64).sqrt().floor() as usize { flg |= v % i == 0; } if !flg { result += cnt; } } println!("{}", result); }