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 limit = n.len(); let cnt0 = vec![1, 0, 0, 0, 0, 0, 0, 0, 0, 0]; let cnt2 = vec![0, 0, 1, 0, 2, 0, 1, 0, 2, 0]; let cnt5 = vec![0, 0, 0, 0, 0, 1, 0, 0, 0, 0]; let mut edp = vec![vec![vec![vec![vec![0usize; 3]; 3]; 2]; 2]; limit]; let mut ldp = vec![vec![vec![vec![vec![0usize; 3]; 3]; 2]; 2]; limit]; edp[0][0][0][cnt2[n[0]]][cnt5[n[0]]] = 1; for i in 0..n[0] { ldp[0][cnt0[i]][0][cnt2[i]][cnt5[i]] += 1; } for i in 1..limit { for lead0 in 0..2 { for cons0 in 0..2 { for div2 in 0..3 { for div5 in 0..3 { for j in 0..10 { let nlead0 = if lead0 == 1 && j == 0 { 1 } else { 0 }; let ncons0 = if cons0 == 1 || (lead0 == 0 && j == 0) { 1 } else { 0 }; let ndiv2 = 2.min(div2 + cnt2[j]); let ndiv5 = 2.min(div5 + cnt5[j]); if j == n[i] { edp[i][nlead0][ncons0][ndiv2][ndiv5] += edp[i-1][lead0][cons0][div2][div5]; } else if j < n[i] { ldp[i][nlead0][ncons0][ndiv2][ndiv5] += edp[i-1][lead0][cons0][div2][div5]; } ldp[i][nlead0][ncons0][ndiv2][ndiv5] += ldp[i-1][lead0][cons0][div2][div5]; ldp[i][nlead0][ncons0][ndiv2][ndiv5] %= MOD; } } } } } } println!("{}", (edp[limit-1][0][0][2][2] + ldp[limit-1][0][0][2][2]) % MOD); }