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 SIZE = n.len(); let map0 = vec![1,0,0,0,0,0,0,0,0,0]; let map2 = vec![0,0,1,0,2,0,1,0,2,0]; let map5 = vec![0,0,0,0,0,1,0,0,0,0]; // n -> leading0 -> 0 included -> 2 times -> 5 times let mut edp = vec![vec![vec![vec![vec![0usize; 3]; 3]; 2]; 2]; SIZE]; let mut ldp = vec![vec![vec![vec![vec![0usize; 3]; 3]; 2]; 2]; SIZE]; edp[0][0][0][map2[n[0]]][map5[n[0]]] = 1; for i in 0..n[0] { ldp[0][map0[i]][0][map2[i]][map5[i]] += 1; } for i in 1..SIZE { for leading0 in 0..2 { for inc0 in 0..2 { for time2 in 0..3 { for time5 in 0..3 { for j in 0..10 { let nleading0 = if leading0 == 1 && j == 0 { 1 } else { 0 }; let ninc0 = if leading0 == 1 || (inc0 == 0 && j > 0) { 0 } else { 1 }; let ntime2 = (time2+map2[j]).min(2); let ntime5 = (time5+map5[j]).min(2); if j == n[i] { edp[i][nleading0][ninc0][ntime2][ntime5] += edp[i-1][leading0][inc0][time2][time5]; } else if j < n[i] { ldp[i][nleading0][ninc0][ntime2][ntime5] += edp[i-1][leading0][inc0][time2][time5]; } ldp[i][nleading0][ninc0][ntime2][ntime5] += ldp[i-1][leading0][inc0][time2][time5]; ldp[i][nleading0][ninc0][ntime2][ntime5] %= MOD; } } } } } } println!("{}", (edp[SIZE-1][0][0][2][2] + ldp[SIZE-1][0][0][2][2]) % MOD); }