#include <bits/stdc++.h>
using namespace std;
long long fpm(long long b, long long e, long long m) {
  long long t = 1;
  for (; e; e >>= 1, b = b * b % m) e & 1 ? t = t * b % m : 0;
  return t;
}
template <class T>
inline bool chkmin(T &a, T b) {
  return a > b ? a = b, true : false;
}
template <class T>
inline bool chkmax(T &a, T b) {
  return a < b ? a = b, true : false;
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
template <class edge>
struct Graph {
  vector<vector<edge> > adj;
  Graph(int n) {
    adj.clear();
    adj.resize(n + 5);
  }
  Graph() { adj.clear(); }
  void resize(int n) { adj.resize(n + 5); }
  void add(int s, edge e) { adj[s].push_back(e); }
  void del(int s, edge e) { adj[s].erase(find(iter(adj[s]), e)); }
  int deg(int v) { return adj[v].size(); }
  vector<edge> &operator[](int t) { return adj[t]; }
};
const int maxL = 30, mod = 1000000007;
long long v[maxL];
long long cb[maxL][maxL];
void dfs(long long m, long long div, long long bef, long long len,
         long long cnt) {
  if (div == 0) {
    ++v[cnt];
    return;
  }
  long long x = m / div % 10;
  if (m / div / 10 != bef) {
    for (long long i = 0; i <= len; ++i)
      v[i + cnt] += cb[len][i] * fpm(2, i, mod) * fpm(8, len - i, mod);
    return;
  }
  for (long long i = 0; i <= x; ++i)
    dfs(m, div / 10, bef * 10 + i, len - 1, cnt + (i == 4 || i == 7));
}
long long inv[maxL];
long long ans = 0;
void search(long long d, long long sum = 1, long long cnt = 1,
            long long rem = 6) {
  if (rem == 0) {
    for (; sum < maxL && v[sum]; ++sum) (ans += cnt * v[sum]) %= mod;
    return;
  }
  if (sum >= maxL || !v[sum] || (rem && !v[d])) return;
  for (long long i = 0; i <= rem; ++i) {
    search(d + 1, sum + i * d, cnt * cb[rem][i] % mod, rem - i);
    cnt = cnt * (mod + v[d] - i) % mod;
  }
}
long long calc(long long x) {
  long long ret = 0;
  for (; x; x /= 10) ret += x % 10 == 4 || x % 10 == 7;
  return ret;
}
long long w[20];
int main() {
  ios_base::sync_with_stdio(false);
  long long m;
  for (long long i = 0; i <= 20; ++i)
    for (long long j = 0; j <= i; ++j)
      cb[i][j] = j ? cb[i - 1][j - 1] + cb[i - 1][j] : 1;
  inv[1] = 1;
  for (long long i = 2; i <= 20; ++i)
    inv[i] = (mod - mod / i) * inv[mod % i] % mod;
  cin >> m;
  dfs(m, 1e9, 0, 10, 0), --v[0];
  for (long long i = 0; i <= 10; ++i) cerr << v[i] << endl;
  search(0);
  cout << ans % mod << endl;
  return 0;
}
