#line 1 "main.cpp" #include #include #include #include #include using namespace std; using mint = atcoder::modint1000000007; void solve() { string s; cin >> s; reverse(s.begin(), s.end()); auto dp = vector(2, vector(3, vector(3, mint(0)))); dp[0][0][0] = dp[1][0][0] = 1; mint ans = 0; for (auto ci : s) { ans += dp[0][2][2]; int c = ci - '0'; auto ndp = vector(2, vector(3, vector(3, mint(0)))); for (int d = 1; d <= 9; ++d) { for (int i = 0; i < 3; ++i) { for (int j = 0; j < 3; ++j) { int ni = i, nj = j; { int x = d; while (x % 2 == 0) { x /= 2; ++ni; } while (x % 5 == 0) { x /= 5; ++nj; } ni = min(ni, 2); nj = min(nj, 2); } // all -> all ndp[0][ni][nj] += dp[0][i][j]; // all -> sub if (d < c) ndp[1][ni][nj] += dp[0][i][j]; // sub -> sub if (d == c) ndp[1][ni][nj] += dp[1][i][j]; } } } swap(dp, ndp); } ans += dp[1][2][2]; cout << ans.val() << "\n"; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); solve(); return 0; }