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![vec![vec![0usize; 3]; 3]; 2]; 2]; n.len()]; let mut ldp = vec![vec![vec![vec![vec![0usize; 3]; 3]; 2]; 2]; n.len()]; let mul2 = vec![0, 0, 1, 0, 2, 0, 1, 0, 2, 0]; let mul5 = vec![0, 0, 0, 0, 0, 1, 0, 0, 0, 0]; edp[0][0][0][mul5[n[0]]][mul2[n[0]]] = 1; for i in 0..n[0] { ldp[0][if i == 0 { 1 } else { 0 }][0][mul5[i]][mul2[i]] += 1; } for i in 1..n.len() { for lead0 in 0..2 { for inc0 in 0..2 { for multi5 in 0..3 { for multi2 in 0..3 { for j in 0..10 { let nlead0 = if lead0 == 1 && j == 0 { 1 } else { 0 }; let ninc0 = if inc0 == 1 || (lead0 == 0 && j == 0) { 1 } else { 0 }; let nmulti5 = 2.min(multi5 + mul5[j]); let nmulti2 = 2.min(multi2 + mul2[j]); if n[i] == j { edp[i][nlead0][ninc0][nmulti5][nmulti2] += edp[i-1][lead0][inc0][multi5][multi2]; } else if j < n[i] { ldp[i][nlead0][ninc0][nmulti5][nmulti2] += edp[i-1][lead0][inc0][multi5][multi2]; } ldp[i][nlead0][ninc0][nmulti5][nmulti2] += ldp[i-1][lead0][inc0][multi5][multi2]; ldp[i][nlead0][ninc0][nmulti5][nmulti2] %= MOD; } } } } } } println!("{}", (MOD + edp[n.len()-1][0][0][2][2] + ldp[n.len()-1][0][0][2][2]) % MOD); }