#include <bits/stdc++.h>
using namespace std;
const long long INF = 1000000007, M = 15;
long long cnt, t[M], m, dp[M][M], num[M], prt[M], vis[M], vv[M], tmp, sum;
void ycl() {
  while (m) t[++cnt] = m % 10, m /= 10;
}
inline long long read() {
  long long s = 0, k = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') k = -1;
    ch = getchar();
  }
  while (ch <= '9' && ch >= '0') {
    s = s * 10 + ch - '0';
    ch = getchar();
  }
  return s * k;
}
long long dfs1(long long pos, long long n, bool fl, long long k) {
  if (n > k) return 0;
  if (pos == 0) return n == k;
  if (!fl && dp[pos][n] != -1) return dp[pos][n];
  long long mix = fl ? t[pos] : 9;
  long long s = 0;
  for (long long i = 0; i <= mix; i++) {
    if (i == 4 || i == 7)
      s += dfs1(pos - 1, n + 1, fl && i == mix, k);
    else
      s += dfs1(pos - 1, n, fl && i == mix, k);
  }
  return fl ? s : dp[pos][n] = s;
}
void dfs2(long long n, long long val) {
  if (n >= 7) {
    memset(vv, 0, sizeof vv);
    long long s = 1;
    for (long long i = 1; i <= 6; i++) {
      s *= (num[prt[i]] - vv[prt[i]]);
      s %= INF;
      vv[prt[i]]++;
    }
    tmp += s;
    return;
  }
  for (long long i = 0; i <= val; i++) {
    if (vis[i] < num[i]) vis[i]++, prt[n] = i, dfs2(n + 1, val - i), vis[i]--;
  }
}
void init() {
  m = read();
  ycl();
  for (long long i = 0; i <= 9; i++) {
    memset(dp, -1, sizeof dp);
    num[i] = dfs1(cnt, 0, 1, i);
  }
  num[0]--;
  for (long long i = 1; i <= 9; i++) {
    if (!num[i]) continue;
    memset(vis, 0, sizeof vis);
    tmp = 0;
    dfs2(1, i - 1);
    tmp *= num[i];
    sum += tmp;
    sum %= INF;
  }
  printf("%lld\n", sum);
  return;
}
int main() {
  init();
  return 0;
}
