#pragma region #define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //#include // using namespace std; //using namespace atcoder; //using mint = modint1000000007; ////using mint = modint998244353; ////using mint = modint; typedef long long ll; using vi = vector; using vvi = vector; using vl = vector; using vvl = vector; using pint = pair; using pll = pair; //#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i)) #define rep(i, e) for (int(i) = 0; (i) < (e); ++(i)) #define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i)) #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #pragma region UnionFind struct UnionFind { vector par; UnionFind(int n) : par(n, -1) {} void init(int n) { par.assign(n, -1); } int root(int x) { if (par[x] < 0) return x; else return par[x] = root(par[x]); } bool issame(int x, int y) { return root(x) == root(y); } bool merge(int x, int y) { x = root(x); y = root(y); if (x == y) return false; if (par[x] > par[y]) swap(x, y); par[x] += par[y]; par[y] = x; return true; } int size(int x) { return -par[root(x)]; } }; #pragma endregion #pragma region GCD ll gcd(ll a, ll b) { if (b == 0)return a; return gcd(b, a % b); } #pragma endregion #pragma region LCM ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } #pragma endregion #pragma region chmin template inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } #pragma endregion #pragma region chmax template inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } #pragma endregion #pragma region グリッド内チェック bool out(int x, int y, int h, int w) { if (x < 0 || h <= x || y < 0 || w <= y)return true; else return false; } #pragma endregion #pragma region Dijkstra vl dijkstra(vector>> v, int s) { ll INF = 1e18; int MAX = 1e6; vl res(MAX, INF); priority_queue, vector>, greater>> q; q.push({ 0,s }); while (!q.empty()) { int now; ll d; tie(d, now) = q.top(); q.pop(); if (!chmin(res[now], d))continue; for (auto p : v[now]) { int next; ll c; tie(next, c) = p; if (res[next] <= res[now] + c)continue; q.push({ res[now] + c,next }); } } return res; } #pragma endregion #pragma endregion const int MOD = 1e9 + 7; ll dp[10101][2][3][3]; int f(string s) { int l = s.size(); rep(i, l) { int D = s[i] - '0'; rep(j, 2)rep(k, 3)rep(m, 3) { for (int d = 1; d <= (j ? 9 : D); ++d) { int cnt = 0; int x = d; while (x % 2 == 0) { ++cnt; x /= 2; } dp[i + 1][j | (d < D)][min(2, k + cnt)][min(2, m + (d == 5))] += dp[i][j][k][m]; dp[i + 1][j | (d < D)][min(2, k + (d % 2 == 0))][min(2, m + (d == 5))] %= MOD; } } } ll res = dp[l][0][2][2] + dp[l][1][2][2]; res %= MOD; return res; } int main() { string n; cin >> n; rep(i, 10101)rep(j, 2)rep(k, 3)rep(l, 3)dp[i][j][k][l] = 0; dp[0][0][0][0] = 1; for (int i = 1; i < 10101; ++i)dp[i][1][0][0] = 1; cout << f(n) << endl; }