const MOD: usize = 1e9 as usize + 7; fn main() { let mut n = String::new(); std::io::stdin().read_line(&mut n).ok(); let n = n.trim().chars().map(|c| c as usize - '0' as usize).collect::>(); let mut edp = vec![vec![vec![0usize; 10]; 2]; n.len()]; let mut ldp = vec![vec![vec![0usize; 10]; 2]; n.len()]; edp[0][0][n[0]] += n[0]; for i in 0..n[0] { ldp[0][if i == 0 { 1 } else { 0 }][i] += if i == 0 { 1 } else { i }; } for i in 1..n.len() { for leading0 in 0..2 { for pval in 0..10 { for cval in 0..10 { let nleading0 = if leading0 == 1 && cval == 0 { 1 } else { 0 }; let nval = if nleading0 == 1 { 1 } else { cval }; if n[i] == cval { edp[i][nleading0][cval] += edp[i-1][leading0][pval] * nval; edp[i][nleading0][cval] %= MOD; } else if n[i] > cval { ldp[i][nleading0][cval] += edp[i-1][leading0][pval] * nval; } ldp[i][nleading0][cval] += ldp[i-1][leading0][pval] * nval % MOD; ldp[i][nleading0][cval] %= MOD; } } } } let lsum = ldp[n.len()-1].iter().map(|v| v.iter().sum::()).sum::() % MOD; let esum = edp[n.len()-1].iter().map(|v| v.iter().sum::()).sum::() % MOD; let result = (lsum + esum - 1) % MOD; println!("{}", result); }