#include using namespace std; using ll = long long; const ll modc = 1e9+7; class mint { ll x; public: mint(ll x=0) : x((x%modc+modc)%modc) {} mint operator-() const { return mint(-x); } mint& operator+=(const mint& a) { if ((x += a.x) >= modc) x -= modc; return *this; } mint& operator-=(const mint& a) { if ((x += modc-a.x) >= modc) x -= modc; return *this; } mint& operator*=(const mint& a) { (x *= a.x) %= modc; return *this; } mint operator+(const mint& a) const { mint res(*this); return res+=a; } mint operator-(const mint& a) const { mint res(*this); return res-=a; } mint operator*(const mint& a) const { mint res(*this); return res*=a; } mint pow(ll t) const { if (!t) return 1; mint a = pow(t>>1); a *= a; if (t&1) a *= *this; return a; } mint inv() const { return pow(modc-2); } mint& operator/=(const mint& a) { return (*this) *= a.inv(); } mint operator/(const mint& a) const { mint res(*this); return res/=a; } bool operator == (const mint& a) const{ return x == a.x; } friend ostream& operator<<(ostream& os, const mint& m){ os << m.x; return os; } friend istream& operator>>(istream& ip, mint &m) { ll t; ip >> t; m = mint(t); return ip; } }; int main(){ ll N, c, d; string S; cin >> S; N = S.size(); vector>>> dp(N+1, vector(3, vector(3, vector(2)))); for (int i=1; i<=N; i++) dp[i][0][0][1] = 1; dp[0][0][0][0] = 1; for (int i=1; i<=N; i++){ c = S[i-1]-'0'; for (int j=1; j<=9; j++){ for (int k=0; k<=2; k++){ for (int l=0; l<=2; l++){ for (int m=0; m<2; m++){ int nk=k, nl=l, nm=m; if (m == 0 && c < j) continue; if (c > j) nm=1; if (j % 4 == 0) nk+=2; else if (j % 2 == 0) nk+=1; if (j % 5 == 0) nl+=1; nk = min(nk, 2); nl = min(nl, 2); dp[i][nk][nl][nm] += dp[i-1][k][l][m]; } } } } } cout << (dp[N][2][2][0]+dp[N][2][2][1]) << endl; return 0; }