#include //#include //#pragma GCC optimize("Ofast") using namespace std; #define reps(i,s,n) for(int i = s; i < n; i++) #define rep(i,n) reps(i,0,n) #define Rreps(i,n,e) for(int i = n - 1; i >= e; --i) #define Rrep(i,n) Rreps(i,n,0) #define ALL(a) a.begin(), a.end() using ll = long long; using vec = vector; using mat = vector; ll N,M,H,W,Q,K,A,B; string S; using P = pair; const ll INF = (1LL<<60); template bool chmin(T &a, const T b){ if(a > b) {a = b; return true;} else return false; } template bool chmax(T &a, const T b){ if(a < b) {a = b; return true;} else return false; } template void my_printv(std::vector v,bool endline = true){ if(!v.empty()){ for(std::size_t i{}; i class modint{ public: ll x; constexpr modint(){x = 0;} constexpr modint(ll _x) : x((_x < 0 ? ((_x += (LLONG_MAX / mod) * mod) < 0 ? _x + (LLONG_MAX / mod) * mod : _x) : _x)%mod){} constexpr modint set_raw(ll _x){ //_x in [0, mod) x = _x; return *this; } constexpr modint operator-(){ return x == 0 ? 0 : mod - x; } constexpr modint& operator+=(const modint& a){ if((x += a.x) >= mod) x -= mod; return *this; } constexpr modint operator+(const modint& a) const{ return modint(*this) += a; } constexpr modint& operator-=(const modint& a){ if((x -= a.x) < 0) x += mod; return *this; } constexpr modint operator-(const modint& a) const{ return modint(*this) -= a; } constexpr modint& operator*=(const modint& a){ (x *= a.x)%=mod; return *this; } constexpr modint operator*(const modint& a) const{ return modint(*this) *= a; } constexpr modint pow(unsigned long long pw) const{ modint res(1), comp(*this); while(pw){ if(pw&1) res *= comp; comp *= comp; pw >>= 1; } return res; } //以下、modが素数のときのみ constexpr modint inv() const{ if(x == 2) return (mod + 1) >> 1; return modint(*this).pow(mod - 2); } constexpr modint& operator/=(const modint &a){ (x *= a.inv().x)%=mod; return *this; } constexpr modint operator/(const modint &a) const{ return modint(*this) /= a; } constexpr bool sqrt(bool find_mini = false) { if(x == 0) return true; modint jge = this->pow((mod - 1)>>1); if(jge.x + 1 == mod) return false; if((mod&3) == 3){ *this = this->pow((mod + 1)>>2); }else{ int m = 0; modint c, t; if(mod == 998244353){ m = 23; c = 15311432; t = this->pow(119); *this = this->pow(60); }else{ ll q = mod - 1; modint z = 2; while(!(q&1)){q>>=1; ++m;} while(z.pow((mod-1)>>1).x == 1) z += 1; c = z.pow(q); t = this->pow(q); *this = this->pow((q+1)>>1); } while(t.x != 1){ modint cpy_t = t; int pw = m; while(cpy_t.x != 1){--pw; cpy_t *= cpy_t;} rep(i, pw-1) c *= c; (*this) *= c; c *= c; t *= c; m -= pw; } } if(find_mini) this->x = min(this->x, (ll)mod - this->x); return true; } }; #define mod2 1000000007 using mint = modint; ostream& operator<<(ostream& os, const mint& a){ os << a.x; return os; } using vm = vector; using matm = vector; int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); cin>>S; N = S.size(); vector dp(N + 1, matm(3, vm(3, 0))), udp = dp; udp[0][0][0] = 1; rep(index, N){ int c = S[index] - '0'; matm &last = dp[index], &nxt = dp[index+1], &ulast = udp[index], &unxt = udp[index+1]; reps(k, 1, 10){ rep(i, 3) { rep(j, 3) { if (k < c) { nxt[min(2, i + (k%2 == 0) + (k%4 == 0))][min(2, j + (k%5 == 0))] += last[i][j] + ulast[i][j]; } else if (k == c) { nxt[min(2, i + (k%2 == 0) + (k%4 == 0))][min(2, j + (k%5 == 0))] += last[i][j]; unxt[min(2, i + (k%2 == 0) + (k%4 == 0))][min(2, j + (k%5 == 0))] += ulast[i][j]; } else { nxt[min(2, i + (k%2 == 0) + (k%4 == 0))][min(2, j + (k%5 == 0))] += last[i][j]; } } } } nxt[0][0] += 1; } cout<