#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:64000000")
using namespace std;
const long double PI = 3.14159265358979323846;
const long double gammama = 0.57721566490153286060;
const long double eps = 1e-8;
const long long INF = 777777777777 + 1;
vector<int> a(10, 0);
int pow(int x, int st) {
  int res = 1;
  for (int i = 0; i < st; ++i) res *= x;
  return res;
}
long long c(int n, int k) {
  long long res = 1;
  for (int i = 0; i < k; ++i) {
    res *= n - i;
    res /= i + 1;
  }
  return res;
}
void add(long long m, int shift) {
  if (m < 1) return;
  if (m == 1) {
    ++a[shift];
    return;
  }
  if (m <= 10) {
    for (int i = 0; i < m; ++i) {
      if ((i == 4) || (i == 7))
        ++a[shift + 1];
      else
        ++a[shift];
    }
    return;
  }
  long long d = 1;
  int s = 0;
  while (d * 10 <= m) {
    d *= 10;
    ++s;
  }
  if (m == d) {
    a[shift] += pow(8, s);
    for (int i = 1; i <= s; ++i) {
      a[shift + i] += c(s, i) * pow(2, i) * pow(8, s - i);
    }
    return;
  }
  int x = m / d;
  for (int i = 0; i < x; ++i) {
    if ((i == 4) || (i == 7))
      add(d, shift + 1);
    else
      add(d, shift);
  }
  if ((x == 4) || (x == 7)) ++shift;
  add(m - d * x, shift);
}
const long long inv[] = {0,        1,         500000004, 166666668,
                         41666667, 808333339, 301388891};
long long mod = 1000 * 1000 * 1000 + 7;
long long cm(long long n, int k) {
  long long res = 1;
  for (int i = 0; i < k; ++i) {
    res = (res * (n - i)) % mod;
  }
  res = (res * inv[k]) % mod;
  return res;
}
long long get(int s, int k) {
  if (k == 0) return 1;
  long long res = 0;
  for (int i = 0; i < s; ++i) {
    --a[i];
    if (a[i] >= 0)
      res = (res + (long long)(a[i] + 1) * get(s - i, k - 1)) % mod;
    ++a[i];
  }
  return res;
}
int main() {
  long long m;
  cin >> m;
  add(m + 1, 0);
  --a[0];
  long long res = 0;
  for (int s = 1; s <= 9; ++s) {
    long long cur = ((long long)(a[s]) * get(s, 6)) % mod;
    res = (res + cur) % mod;
  }
  cout << res << endl;
  return 0;
}
