#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1073741824")
using namespace std;
const long long mod = 1000000007;
vector<int> have(10);
vector<int> operator+(vector<int> a, vector<int> b) {
  for (int(i) = 0; (i) < (int((a).size())); ++(i)) a[i] += b[i];
  return a;
}
vector<int> operator*(vector<int> a, int b) {
  for (int(i) = 0; (i) < (int((a).size())); ++(i)) a[i] *= b;
  return a;
}
vector<int> operator<<(vector<int> a, int b) {
  for (int(i) = ((int((a).size()))); (i)--;)
    if (i + b < (int((a).size()))) a[i + b] = a[i];
  for (int(i) = 0; (i) < (b); ++(i)) a[i] = 0;
  return a;
}
vector<int> full[10];
void print(const vector<int>& a) {
  printf("##\n");
  for (int(i) = 0; (i) < (int((a).size())); ++(i)) printf("%d: %d\n", i, a[i]);
  printf("##\n");
}
vector<int> calc(string nmax) {
  vector<int> res(10);
  int c = nmax[0] - '0';
  if (nmax.size() == 1) {
    res[0] = c + 1;
    if (c >= 7) {
      ++res[1];
      --res[0];
    }
    if (c >= 4) {
      ++res[1];
      --res[0];
    }
  } else {
    vector<int> right_ = calc(nmax.substr(1));
    if (c == 4 || c == 7) right_ = right_ << 1;
    res = res + right_;
    for (int(i) = (0); (i) <= (c - 1); ++(i)) {
      if (i == 4 || i == 7) {
        res = res + (full[nmax.size() - 1] << 1);
      } else {
        res = res + full[nmax.size() - 1];
      }
    }
  }
  return res;
}
long long binpow(long long x, long long n) {
  long long a = 1;
  while (n) {
    if (n & 1) a = a * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return a;
}
long long ans = 0;
void rec(int v, int I, long long ways, int parties, int k = 1) {
  if (I == -1) {
    if (parties != 0) return;
    ans += ways;
    if (ans >= mod) ans -= mod;
    return;
  }
  if (v > I && have[I] && parties) {
    --have[I];
    rec(v - I, I,
        ways * parties % mod * binpow(k, mod - 2) % mod * (have[I] + 1LL) % mod,
        parties - 1, k + 1);
    ++have[I];
  }
  rec(v, I - 1, ways, parties);
}
int main() {
  int n;
  scanf("%d", &n);
  char s[11];
  sprintf(s, "%d", n);
  full[0].assign(10, 0);
  for (int(i) = (1); (i) <= (9); ++(i)) {
    full[i] = calc(string(i, '9'));
  }
  have = calc(string(s));
  --have[0];
  for (int(i) = (1); (i) <= (9); ++(i))
    if (have[i]) {
      --have[i];
      rec(i, 9, have[i] + 1LL, 6);
      ++have[i];
    }
  cout << ans % mod << endl;
  return 0;
}
