#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
long long POW(long long a, long long b, long long MMM = MOD) {
  long long ret = 1;
  for (; b; b >>= 1, a = (a * a) % MMM)
    if (b & 1) ret = (ret * a) % MMM;
  return ret;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) {
  if (a == 0 || b == 0) return a + b;
  return a * (b / gcd(a, b));
}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
int ddx[] = {0, 0, 1, 1, 1, -1, -1, -1}, ddy[] = {1, -1, 1, 0, -1, 1, 0, -1};
char a[11];
long long d[10][10][2];
long long go(int N, int K, int c) {
  if (N == 10) return K == 0;
  long long &ret = d[N][K][c];
  if (ret != -1) return ret;
  ret = 0;
  if (c == 0) {
    for (int(i) = (0); (i) <= (a[N] - 1); (i) += (1)) {
      if (i == 4 || i == 7) {
        if (K) ret = (ret + go(N + 1, K - 1, 1)) % MOD;
      } else
        ret = (ret + go(N + 1, K, 1)) % MOD;
    }
    if (a[N] == 4 || a[N] == 7) {
      if (K) ret = (ret + go(N + 1, K - 1, 0)) % MOD;
    } else
      ret = (ret + go(N + 1, K, 0)) % MOD;
  } else {
    if (K) ret = (ret + 2 * go(N + 1, K - 1, 1)) % MOD;
    ret = (ret + 8 * go(N + 1, K, 1)) % MOD;
  }
  return ret;
}
long long cnt[10];
long long ans;
void dfs(int N, int s, long long t) {
  if (N == 7) {
    if (s > 0) ans = (ans + t) % MOD;
    return;
  }
  for (int(i) = (0); (i) <= (9); (i) += (1)) {
    if (cnt[i] > 0) {
      long long tt = (t * cnt[i]) % MOD;
      cnt[i]--;
      if (N == 0)
        dfs(N + 1, s + i, tt);
      else
        dfs(N + 1, s - i, tt);
      cnt[i]++;
    }
  }
}
int main() {
  memset(d, -1, sizeof(d));
  ;
  int n;
  scanf("%d", &n);
  sprintf(a, "%010d", n);
  for (int(i) = (0); (i) <= (9); (i) += (1)) a[i] = a[i] - '0';
  for (int(i) = (0); (i) <= (9); (i) += (1)) cnt[i] = go(0, i, 0);
  cnt[0]--;
  dfs(0, 0, 1);
  printf("%lld", ans);
}
