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