#include <bits/stdc++.h>
long long modulo = 1000000007;
int SUM = 0;
int values[9] = {6, 0, 0, 0, 0, 0, 0, 0, 0};
int factorial[7] = {1, 1, 2, 6, 24, 120, 720};
void simplify() {
  values[0] = 6;
  for (int i = 1; i < 9; i++) values[i] = 0;
}
int getSum(int start) {
  int summ = 0;
  for (int i = start; i < 9; i++) summ += values[i] * i;
  return summ;
}
int getNum(int start) {
  int summ = 0;
  for (int i = start; i < 9; i++) summ += values[i];
  return summ;
}
bool nextVal() {
  for (int i = 1; i < 9; i++) {
    values[i]++;
    if (getSum(i) < SUM && getNum(i) < 7) {
      int k = 6 - getNum(i);
      for (int j = 0; j < i; j++) values[j] = 0;
      values[0] = k;
      return true;
    }
    values[i]--;
  }
  return false;
}
int main(int argc, const char* argv[]) {
  int m, M[10];
  long long K[10][10], res[10], result = 0;
  scanf("%d", &m);
  bool wasModified = false;
  if (m == 1000000000) {
    m--;
    wasModified = true;
  }
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) K[i][j] = 0;
    M[i] = 0;
    res[i] = 0;
  }
  K[1][1] = 2;
  K[1][0] = 8;
  for (int i = 2; i < 10; i++)
    for (int j = 0; j <= i; j++)
      if (j == 0) {
        K[i][j] = K[i - 1][j] * 8;
      } else
        K[i][j] = K[i - 1][j] * 8 + K[i - 1][j - 1] * 2;
  int p = 0, hn = 0;
  for (; m > 0; p++) {
    M[p] = m % 10;
    m /= 10;
  }
  p--;
  for (; p >= 0; p--) {
    for (int i = 0; i < 10; i++) {
      int MP = M[p];
      if (MP < 1) continue;
      if (M[p] <= 4)
        res[i + hn] += K[p][i] * MP;
      else if (M[p] <= 7) {
        res[i + hn] += K[p][i] * (MP - 1);
        res[i + 1 + hn] += K[p][i];
      } else {
        res[i + hn] += K[p][i] * (MP - 2);
        res[i + 1 + hn] += 2 * K[p][i];
      }
    }
    if ((M[p] == 4 || M[p] == 7) && p > 0) hn++;
  }
  if (M[0] < 4)
    res[hn] += M[0] + 1;
  else if (M[0] < 7) {
    res[hn] += M[0];
    res[hn + 1] += 1;
  } else {
    res[hn] += M[0] - 1;
    res[hn + 1] += 2;
  }
  if (!wasModified) res[0]--;
  for (int i = 9; i > 0; i--) {
    long long dod = 1;
    if (res[i] < 1) continue;
    SUM = i;
    simplify();
    long long mnoj[6];
    do {
      dod = 1;
      int J = 0;
      for (int k = 0; k < 9; k++)
        for (int j = 0; j < values[k]; j++, J++) mnoj[J] = res[k] - j;
      for (int j = 0; j < 6; j++) dod = (dod * mnoj[j]) % modulo;
      int factor = factorial[6];
      for (int i = 0; i < 9; i++) factor /= factorial[values[i]];
      dod = (dod * factor) % modulo;
      dod = (dod * res[i]) % modulo;
      result = (result + dod) % modulo;
    } while (nextVal());
  }
  std::cout << result;
  return 0;
}
