#include <bits/stdc++.h>
int mod = 1000000007;
int a[16];
int s[10];
int m2[10], m8[10];
int c[10][10];
int res;
int ff[7];
int rr[7];
int cc(int x, int y) {
  int i;
  for (i = 0; i < y; i++) rr[i] = s[x] - i;
  if (y >= 2) {
    for (i = 0; i < y; i++)
      if (rr[i] % 2 == 0) {
        rr[i] = rr[i] / 2;
        break;
      }
  }
  if (y >= 3) {
    for (i = 0; i < y; i++)
      if (rr[i] % 3 == 0) {
        rr[i] = rr[i] / 3;
        break;
      }
  }
  if (y >= 4) {
    for (i = 0; i < y; i++)
      if (rr[i] % 2 == 0) {
        rr[i] = rr[i] / 2;
        break;
      }
    for (i = 0; i < y; i++)
      if (rr[i] % 2 == 0) {
        rr[i] = rr[i] / 2;
        break;
      }
  }
  if (y >= 5) {
    for (i = 0; i < y; i++)
      if (rr[i] % 5 == 0) {
        rr[i] = rr[i] / 5;
        break;
      }
  }
  if (y >= 6) {
    for (i = 0; i < y; i++)
      if (rr[i] % 2 == 0) {
        rr[i] = rr[i] / 2;
        break;
      }
    for (i = 0; i < y; i++)
      if (rr[i] % 3 == 0) {
        rr[i] = rr[i] / 3;
        break;
      }
  }
  long long ret = 1;
  for (i = 0; i < y; i++) ret = (ret * rr[i]) % mod;
  return (int)ret;
}
void cal(int x) {
  int i, j;
  long long ret = s[x];
  for (i = 1; i <= 6;) {
    j = i;
    while (i <= 6 && ff[i] == ff[j]) i++;
    ret = (ret * cc(ff[j], i - j)) % mod;
  }
  res = (res + ret * 720) % mod;
}
void dfs(int x, int pr, int tot, int cur) {
  if (x == 7)
    cal(cur);
  else {
    int i;
    if (pr < tot)
      i = pr;
    else
      i = tot;
    for (; i >= 0; i--) {
      ff[x] = i;
      dfs(x + 1, i, tot - i, cur);
    }
  }
}
int main() {
  int m, l;
  int i, j, k, r;
  scanf("%d", &m);
  l = 0;
  while (m > 0) {
    l++;
    a[l] = m % 10;
    m = m / 10;
  }
  memset(s, 0, sizeof(s));
  m2[0] = 1;
  m8[0] = 1;
  for (i = 1; i <= 9; i++) {
    m2[i] = m2[i - 1] * 2;
    m8[i] = m8[i - 1] * 8;
  }
  c[0][0] = 1;
  c[1][0] = 1;
  c[1][1] = 1;
  for (i = 2; i <= 9; i++) {
    c[i][0] = 1;
    for (j = 1; j <= i; j++) c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
  }
  k = 0;
  for (i = l; i >= 1; i--) {
    for (j = 0; j < a[i]; j++) {
      if (j == 4 || j == 7) {
        for (r = 0; r <= i - 1; r++)
          s[r + 1 + k] = s[r + 1 + k] + c[i - 1][r] * m2[r] * m8[i - 1 - r];
      } else {
        for (r = 0; r <= i - 1; r++)
          s[r + k] = s[r + k] + c[i - 1][r] * m2[r] * m8[i - 1 - r];
      }
    }
    if (a[i] == 4 || a[i] == 7) k++;
  }
  s[k]++;
  s[0]--;
  res = 0;
  for (i = 1; i <= l; i++) dfs(1, i - 1, i - 1, i);
  printf("%d\n", res);
  return 0;
}
