#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
long long cnt[11] = {0};
long long c[11][11] = {0};
long long dp[12][7][1000] = {0};
void f(long long a, long long len, long long mul, long long add = 0) {
  if (len == 0) {
    cnt[add] = (cnt[add] + 1) % mod;
    return;
  }
  for (long long i = 0; i < 10; i++) {
    long long iadd = 0;
    if (i == 4 || i == 7) iadd = 1;
    if (a >= (i + 1) * mul) {
      long long nluck = 1, luck = 1;
      for (int j = 1; j <= len - 1; j++) {
        nluck *= 8;
      }
      for (int j = 0; j <= len - 1; j++) {
        cnt[add + j + iadd] =
            (cnt[add + j + iadd] + (luck * nluck * c[len - 1][j]) % mod) % mod;
        luck *= 2;
        nluck /= 8;
      }
    } else {
      f(a - i * mul, len - 1, mul / 10, add + iadd);
      return;
    }
  }
}
long long rec(int k, int n, int t) {
  if (k == 11) return (n == 6);
  long long r = 0;
  long long mul = 1;
  long long val;
  for (int i = 0; i + n <= 6; i++) {
    if (i > cnt[k] || t - i * k < 0) break;
    val = (mul * c[i + n][i]) % mod;
    r = (r + (rec(k + 1, i + n, t - i * k) * val) % mod) % mod;
    mul = (mul * (cnt[k] - i)) % mod;
  }
  return r;
}
void calc(long long v) {
  for (int i = 0; i <= 11; i++) {
    for (int k = 0; k <= 6; k++) {
      for (int j = 0; j <= 10; j++) {
        dp[i][k][j] = 0;
      }
    }
  }
  dp[0][0][0] = v;
  for (int i = 0; i <= 10; i++) {
    for (int k = 0; k < 6; k++) {
      for (int j = 0; j <= 10; j++) {
        long long mul = 1;
        long long val = 1;
        for (int n = 1; n + k <= 6; n++) {
          if (n > cnt[i]) break;
          mul = (mul * (cnt[i] - (n - 1))) % mod;
          val = (mul * c[n + k][k]) % mod;
          dp[i + 1][n + k][j + i * n] =
              (dp[i + 1][n + k][j + i * n] + (dp[i][k][j] * val) % mod) % mod;
        }
      }
    }
  }
}
int main() {
  long long n;
  cin >> n;
  c[0][0] = 1;
  for (int i = 1; i <= 10; i++) {
    c[i][0] = 1;
    for (int j = 1; j <= i; j++) {
      c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
    }
  }
  long long len = 1;
  long long mul = 1;
  while (mul * 10 <= n) {
    len++;
    mul *= 10;
  }
  f(n, len, mul);
  cnt[0]--;
  long long temp = 0;
  for (int i = 0; i <= 10; i++) {
    if (cnt[i] == 0) continue;
    cnt[i]--;
    calc(cnt[i] + 1);
    for (int k = 1; k <= 11; k++) {
      for (int j = 0; j < i; j++) {
      }
    }
    temp = (temp + rec(0, 0, i - 1) * (cnt[i] + 1)) % mod;
    cnt[i]++;
  }
  cout << temp;
}
