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 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]; let cnt2s = vec![0, 0, 1, 0, 2, 0, 1, 0, 2, 0]; let cnt5s = vec![0, 0, 0, 0, 0, 1, 0, 0, 0, 0]; edp[n[0]][0][0][cnt2s[n[0]]][cnt5s[n[0]]] = 1; for i in 0..n[0] { ldp[0][if i==0 { 1 } else { 0 }][0][cnt2s[i]][cnt5s[i]] += 1; } for i in 0..limit-1 { for leading0 in 0..2 { for cons0 in 0..2 { for cnt2 in 0..3 { for cnt5 in 0..3 { for j in 0..10 { let nleading0 = if leading0 == 1 && j == 0 { 1 } else { 0 }; let ncons0 = if cons0 == 1 || (leading0 == 0 && j == 0) { 1 } else { 0 }; let ncnt2 = 2.min(cnt2 + cnt2s[j]); let ncnt5 = 2.min(cnt5 + cnt5s[j]); if j == n[i+1] { edp[i+1][nleading0][ncons0][ncnt2][ncnt5] += edp[i][leading0][cons0][cnt2][cnt5]; } else if j < n[i+1] { ldp[i+1][nleading0][ncons0][ncnt2][ncnt5] += edp[i][leading0][cons0][cnt2][cnt5]; } ldp[i+1][nleading0][ncons0][ncnt2][ncnt5] += ldp[i][leading0][cons0][cnt2][cnt5]; ldp[i+1][nleading0][ncons0][ncnt2][ncnt5] %= MOD; } } } } } } println!("{}", (edp[limit-1][0][0][2][2] + ldp[limit-1][0][0][2][2]) % MOD); }