#include <bits/stdc++.h>
using namespace std;
const int P = 1000000007;
char s[14];
int n, ans, A[11], cnt[11], J[11], V[11], len, lw, f[11][11][11];
bool ok, B[11][11];
void fly(int x, int d, bool fl) {
  if (fl) {
    memset(f[x][d], 0, sizeof(f[x][d]));
    B[x][d] = false;
  }
  if (d > lw + 1) return;
  if (B[x][d]) return;
  if (d == lw + 1) f[x][d][(x == 4 || x == 7)] = 1;
  B[x][d] = true;
  if (fl)
    for (int i = 0; i <= s[d] - '0'; ++i) {
      fly(i, d + 1, i == (s[d] - '0'));
      for (int j = 0; j <= 9; ++j)
        f[x][d][j + (x == 4 || x == 7)] =
            (f[x][d][j + (x == 4 || x == 7)] + f[i][d + 1][j]) % P;
    }
  else
    for (int i = 0; i <= 9; ++i) {
      fly(i, d + 1, false);
      for (int j = 0; j <= 9; ++j)
        f[x][d][j + (x == 4 || x == 7)] =
            (f[x][d][j + (x == 4 || x == 7)] + f[i][d + 1][j]) % P;
    }
}
int Pow(int x, int k) {
  int res = 1;
  while (k) {
    if (k & 1) res = 1LL * res * x % P;
    x = 1LL * x * x % P;
    k >>= 1;
  }
  return res;
}
int C(int n, int m) {
  int res = 1;
  for (int i = 1; i <= m; ++i) {
    res = 1LL * res * (n - i + 1) % P;
    res = 1LL * res * V[i] % P;
  }
  return res;
}
int main() {
  scanf("%s", s + 1);
  len = strlen(s + 1);
  sscanf(s + 1, "%d", &n);
  for (lw = 1; lw < len; ++lw) {
    for (int i = 1; i <= 9; ++i) {
      memset(B, false, sizeof(B));
      memset(f, 0, sizeof(f));
      fly(i, 2, false);
      for (int j = 0; j <= 9; ++j) A[j] += f[i][2][j];
    }
  }
  for (int i = 1; i <= s[1] - '0'; ++i) {
    memset(B, false, sizeof(B));
    memset(f, 0, sizeof(f));
    fly(i, 2, i == s[1] - '0');
    for (int j = 0; j <= 10; ++j) A[j] += f[i][2][j];
  }
  for (int i = 1; i <= 10; ++i) V[i] = Pow(i, P - 2);
  V[0] = J[0] = 1;
  for (int i = 1; i <= 10; ++i) J[i] = 1LL * J[i - 1] * i % P;
  for (int g = 1; g <= 9; ++g)
    for (int j = 0; j <= g - 1; ++j)
      for (int a = 0; a <= j; ++a)
        for (int b = 0; b <= j - a; ++b)
          for (int c = 0; c <= j - a - b; ++c)
            for (int d = 0; d <= j - a - b - c; ++d)
              for (int e = 0; e <= j - a - b - c - d; ++e) {
                int f = j - a - b - c - d - e;
                int res = 1;
                ++cnt[a];
                ++cnt[b];
                ++cnt[c];
                ++cnt[d];
                ++cnt[e];
                ++cnt[f];
                ++cnt[g];
                ok = true;
                for (int k = 0; k <= g; ++k)
                  if (cnt[k] > A[k]) {
                    ok = false;
                    break;
                  } else
                    res = 1LL * res * C(A[k], cnt[k]) % P * J[cnt[k]] % P;
                if (ok) ans = (ans + res) % P;
                --cnt[a];
                --cnt[b];
                --cnt[c];
                --cnt[d];
                --cnt[e];
                --cnt[f];
                --cnt[g];
              }
  printf("%d\n", ans);
  return 0;
}
