#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int dx[8] = {1, 0, -1, 0, -1, -1, 1, 1};
const int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
int m, now;
long long a[12], n[12], pw[12];
int f[12][12];
long long mod = 1000000007;
long long dfs(int i, int s, bool e) {
  if (i == -1) return (s == now);
  if (!e && f[i][s] != -1) return f[i][s];
  long long res = 0;
  int u = e ? n[i] : 9;
  for (int d = 0; d <= u; ++d)
    res += dfs(i - 1, s + (d == 4 || d == 7), e && d == u);
  return e ? res : f[i][s] = res;
}
long long solve(long long x) {
  int l = 0;
  for (; x; x /= 10) n[l++] = x % 10;
  return dfs(l - 1, 0, 1);
}
long long tans;
long long pow(long long a, long long k) {
  if (k == 0) return 1;
  if (k == 1) return a;
  long long tmp = pow(a, k / 2);
  tmp = (tmp * tmp) % mod;
  if (k & 1)
    return (tmp * a) % mod;
  else
    return tmp;
}
long long get2(long long a, long long b) {
  long long ret1 = 1, ret2 = 1;
  for (int i = 1; i <= b; ++i) {
    ret1 = (ret1 * (a - i + 1)) % mod;
    ret2 = (ret2 * i);
  }
  ret1 = (ret1 * (pow(ret2, mod - 2))) % mod;
  return ret1;
}
void get(int deep, int left1, int left2, long long tmp) {
  if (deep == 10) {
    if (!left2) tans = (tans + tmp) % mod;
    return;
  }
  long long t = tmp;
  for (int i = 0; i <= min(a[deep], (long long)left2) && i * deep <= left1; ++i)
    get(deep + 1, left1 - i * deep, left2 - i, (t * get2(a[deep], i)) % mod);
}
long long work(int k) {
  tans = 0;
  get(0, k - 1, 6, a[k]);
  return tans % mod;
}
int main() {
  while (scanf("%d", &m) == 1) {
    pw[0] = 1;
    for (int i = 1; i <= 10; ++i) pw[i] = (pw[i - 1] * i) % mod;
    for (now = 0; now < 10; ++now) {
      memset(f, -1, sizeof(f));
      a[now] = solve(m);
    }
    a[0]--;
    long long ans = 0;
    for (int i = 1; i < 10; ++i) ans = (ans + work(i)) % mod;
    ans = (ans * 720) % mod;
    cout << ans << endl;
  }
  return 0;
}
