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 - '0' as usize).collect::>(); let n = s.len(); let one_cnt = s.iter().sum::(); let summary = (0..n).map(|i| s[i] * (i+1)).sum::(); let mut dp = vec![vec![vec![0usize; summary+1]; one_cnt+1]; n+1]; dp[0][0][0] = 1; for i in 0..n { for j in 0..=one_cnt { for k in 0..=summary { dp[i+1][j][k] += dp[i][j][k]; if j+1 <= one_cnt && i+1+k <= summary { dp[i+1][j+1][i+1+k] += dp[i][j][k]; } } } } println!("{}", dp[n][one_cnt][summary]); }