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; 2]; 10]; n.len()]; let mut ldp = vec![vec![vec![0usize; 2]; 10]; n.len()]; edp[0][n[0]][0] = 1; for i in 0..n[0] { ldp[0][i][if i == 0 { 1 } else { 0 }] += 1; } for i in 1..n.len() { for nj in 0..10 { for cj in 0..10 { for leading0 in 0..2 { if n[i] == nj { edp[i][nj][0] += edp[i-1][cj][leading0] * nj % MOD; } let nleading0 = if leading0 == 1 && nj == 0 { 1 } else { 0 }; let njval = if nleading0 == 1 && nj == 0 { 1 } else { nj }; ldp[i][nj][nleading0] += ldp[i-1][cj][leading0] * njval % MOD; if nj < n[i] { ldp[i][nj][nleading0] += edp[i-1][cj][leading0] * njval % MOD; } ldp[i][nj][nleading0] %= MOD; } } } } let result = (ldp[n.len()-1].iter().map(|v| v.iter().sum::()).sum::() + edp[n.len()-1].iter().map(|v| v.iter().sum::()).sum::() - ldp[n.len()-1][0][1]) % MOD; println!("{}", result); }