#include <bits/stdc++.h>
using namespace std;
int N, L;
vector<int> digit;
long long dp[12][12][12][2];
int A[10] = {0, 1, 2, 3, 4, 4, 5, 6, 6, 7};
int B[10] = {1, 1, 1, 1, 0, 1, 1, 0, 1, 1};
long long recur(int lv, int c4, int c7, bool isTop) {
  if (dp[lv][c4][c7][isTop] != -1) return dp[lv][c4][c7][isTop];
  if (lv == L) {
    if (c4 + c7) return 0;
    return 1;
  } else {
    if (c4 + c7 > L - lv) return 0;
    int lim = 9;
    if (isTop) lim = digit[lv];
    int res = 0;
    if (lim > 6 && c7)
      res = (res + recur(lv + 1, c4, c7 - 1, isTop && digit[lv] == 7)) %
            1000000007;
    if (lim > 3 && c4)
      res = (res + recur(lv + 1, c4 - 1, c7, isTop && digit[lv] == 4)) %
            1000000007;
    if (!isTop)
      res = (res + 8 * recur(lv + 1, c4, c7, 0)) % 1000000007;
    else {
      res = (res + A[lim] * recur(lv + 1, c4, c7, 0)) % 1000000007;
      res = (res + B[lim] * recur(lv + 1, c4, c7, 1)) % 1000000007;
    }
    if (lv == 0 && c4 == 0 && c7 == 0 && isTop)
      res = (res + (1000000007 - 1)) % 1000000007;
    return dp[lv][c4][c7][isTop] = res;
  }
}
long long C[12][12];
long long ans;
void go(int lv, int rem, long long tmp) {
  if (!tmp) return;
  if (lv == 0) {
    ans = (ans + tmp) % 1000000007;
  } else {
    for (int i = (0); i < (L + 1); ++i)
      for (int j = (0); j < (L + 1) && (rem > i + j); ++j) {
        if (C[i][j]) {
          long long q = C[i][j];
          C[i][j]--;
          go(lv - 1, rem - i - j, (tmp * q) % 1000000007);
          C[i][j]++;
        }
      }
  }
}
long long C_bf[12][12];
int main(int argc, char **argv) {
  cin >> N;
  int tmp = N;
  memset(dp, -1, sizeof(dp));
  for (; tmp; tmp /= 10) digit.push_back(tmp % 10);
  reverse(digit.begin(), digit.end());
  L = digit.size();
  for (int j = (0); j < (L + 1); ++j)
    for (int k = (0); k < (L + 1) && (j + k <= L); ++k)
      fprintf(stderr, "With %d 4's, %d 7's, count = %lld\n", j, k,
              C[j][k] = recur(0, j, k, 1));
  for (int j = (0); j < (L + 1); ++j)
    for (int k = (0); k < (L + 1) && (j + k <= L); ++k) go(6, j + k, C[j][k]);
  cout << ans;
  return 0;
}
