#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f, P = 1e9 + 7, N = 30;
template <class T>
inline bool chkmin(T &A, T B) {
  return B < A ? A = B, 1 : 0;
}
template <class T>
inline bool chkmax(T &A, T B) {
  return A < B ? A = B, 1 : 0;
}
template <class T, class _>
inline void Add(T &first, _ second) {
  first += second;
  if (first >= P) first -= P;
  if (first < 0) first += P;
}
int ans, dp[N][N], cnt[N], A[N], tot;
int DP(int now, int cnt, int lim) {
  if (cnt < 0) return 0;
  if (now == -1) return cnt == 0;
  if (!lim && ~dp[now][cnt]) return dp[now][cnt];
  int res = 0;
  for (int i = (0), i_end = (lim ? A[now] : 9); i <= i_end; ++i)
    Add(res, DP(now - 1, cnt - (i == 4 || i == 7), lim && i == i_end));
  if (!lim) dp[now][cnt] = res;
  return res;
}
void calc(char *str) {
  memset(dp, -1, sizeof(dp));
  tot = strlen(str);
  for (int i = (0), i_end = (tot - 1); i <= i_end; ++i)
    A[i] = str[tot - i - 1] - '0';
  for (int i = (0), i_end = (tot); i <= i_end; ++i) cnt[i] = DP(tot - 1, i, 1);
}
long long Pow(long long first, long long k) {
  long long res = 1;
  while (k) {
    if (k & 1) res = res * first % P;
    first = first * first % P;
    k >>= 1;
  }
  return res;
}
long long C(int n, int m) {
  long long res = 1;
  for (int i = (n - m + 1), i_end = (n); i <= i_end; ++i) res = res * i % P;
  for (int i = (1), i_end = (m); i <= i_end; ++i) res = res * Pow(i, P - 2) % P;
  return res;
}
int Solve(int first) {
  int f[2][N][N], cur, w, res = 0;
  memset(f, cur = 0, sizeof(f));
  f[0][0][0] = 1;
  for (int tt = (0), tt_end = (first - 1); tt <= tt_end; ++tt) {
    memset(f[!cur], 0, sizeof(f[cur]));
    for (int i = (0), i_end = (6); i <= i_end; ++i)
      for (int j = (0), j_end = (first - 1); j <= j_end; ++j)
        if ((w = f[cur][i][j]))
          for (int k = (0), k_end = (min(cnt[tt], 6 - i)); k <= k_end; ++k) {
            if (tt * k + j >= first) continue;
            Add(f[!cur][i + k][j + tt * k], w * C(cnt[tt], k) % P);
          }
    cur = !cur;
  }
  for (int i = (0), i_end = (first - 1); i <= i_end; ++i)
    Add(res, f[cur][6][i]);
  return res;
}
int main() {
  char str[N];
  scanf("%s", str);
  calc(str);
  cnt[0]--;
  for (int i = (0), i_end = (19); i <= i_end; ++i)
    if (cnt[i]) {
      --cnt[i];
      Add(ans, (1ll * Solve(i) * (cnt[i] + 1)) % P);
      ++cnt[i];
    }
  for (int i = (1), i_end = (6); i <= i_end; ++i) ans = 1ll * ans * i % P;
  printf("%d\n", ans);
  return 0;
}
