#include <bits/stdc++.h>
int any_table[11][11];
struct DammedPascalNUmber {
  int tb[13][13];
  DammedPascalNUmber() {
    int i, j;
    for (i = 0; i <= 12; i++)
      for (j = 0; j <= i; j++) {
        int &r = tb[i][j];
        if (j == 0 || i == 0)
          r = 1;
        else
          r = tb[i - 1][j - 1] + tb[i - 1][j];
      }
  }
  int count(int n, int m) { return tb[n][m]; }
} pas;
int any(int dig, int amo) {
  if (dig < amo) return 0;
  if (amo < 0) return 0;
  if (dig == 0) return 1;
  int &r = any_table[dig][amo];
  int i;
  if (r >= 0) return r;
  r = 1;
  for (i = 0; i < amo; i++) r *= 2;
  for (; i < dig; i++) r *= 8;
  r *= pas.count(dig, amo);
  return r;
}
int check(int m, int n) {
  int i, j, t, r = 0;
  for (i = 1; i <= m; i++) {
    char str[15];
    t = 0;
    sprintf(str, "%d", i);
    for (j = 0; str[j]; j++)
      if (str[j] == '4' || str[j] == '7') t++;
    if (t == n) r++;
  }
  return r;
}
int a[13];
int dfs(int party, int quta) {
  int r = 0, i;
  if (party == 6) {
    return 1;
  }
  for (i = quta; i >= 0; i--)
    if (a[i] > 0) {
      int t = a[i];
      a[i]--;
      r = (1LL * r + 1LL * t * 1LL * dfs(party + 1, quta - i) +
           1LL * 1000000007) %
          1000000007;
      a[i]++;
    }
  return r;
}
void test(int n, int m) { printf("any(%d,%d)=%d\n", n, m, any(n, m)); }
void test2(int m, int n) {
  printf("(%d,%d)=%d a[%d]=%d\n", m, n, check(m, n), n, a[n]);
}
int main() {
  memset(any_table, -1, sizeof(any_table));
  int m, s, i, j, k, sn, lucked;
  while (~scanf("%d", &m)) {
    memset(a, 0, sizeof(a));
    char str[15];
    sprintf(str, "%d", m);
    for (sn = 0; str[sn]; sn++)
      ;
    for (j = sn; j > 0; j--) {
      a[j] = 0;
      lucked = 0;
      for (i = 0; i < sn; i++) {
        int p = 0, q = 0;
        k = str[i] - '0' - 1;
        for (; k >= 0; k--)
          if (k == 4 || k == 7)
            q++;
          else
            p++;
        if (p) a[j] += p * any(sn - i - 1, j - lucked);
        if (q) a[j] += q * any(sn - i - 1, j - lucked - 1);
        if (str[i] == '4' || str[i] == '7') {
          lucked++;
        }
        if (i == sn - 1 && lucked == j) a[j]++;
      }
    }
    a[0] = m;
    for (i = 1; i <= sn; i++) a[0] -= a[i];
    int ans = 0;
    for (i = 1; i <= sn; i++)
      if (a[i]) {
        ans = (1LL * ans + 1LL * a[i] * dfs(0, i - 1) + 1LL * 1000000007) %
              1000000007;
      }
    printf("%d\n", ans);
  }
}
