#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const int mod = 1000000007;
int D[10][10] = {0};
void init() {
  D[0][0] = 1;
  for (int n = (1), en = (10); n < en; n++) {
    for (int d = (0), ed = (10); d < ed; d++) {
      if (d != 4 && d != 7) {
        D[n][0] += D[n - 1][0];
        for (int k = (1), ek = (10); k < ek; k++) D[n][k] += D[n - 1][k];
      } else {
        for (int k = (1), ek = (10); k < ek; k++) D[n][k] += D[n - 1][k - 1];
      }
    }
  }
}
int calcCnt(int m, int need) {
  char str[20];
  sprintf(str, "%d", m);
  int l = strlen(str);
  reverse(str, str + l);
  int res = 0;
  int has = 0;
  for (int i = l - 1; i >= 0; i--) {
    str[i] -= '0';
    if (str[i] <= 4)
      res += str[i] * D[i][need - has];
    else if (str[i] <= 7) {
      res += 4 * D[i][need - has];
      if (need - has - 1 >= 0) res += D[i][need - has - 1];
      res += (str[i] - 5) * D[i][need - has];
    } else {
      res += 4 * D[i][need - has];
      if (need - has - 1 >= 0) res += D[i][need - has - 1];
      res += 2 * D[i][need - has];
      if (need - has - 1 >= 0) res += D[i][need - has - 1];
      res += (str[i] - 8) * D[i][need - has];
    }
    if (str[i] == 4 || str[i] == 7) ++has;
    if (has > need) break;
  }
  if (has == need) ++res;
  return res;
}
long long res = 0;
int Cnt[10];
void rec(int ind, int sum, int currsum, long long currcnt) {
  if (ind == 6) {
    if (currsum < sum) res = (res + currcnt) % mod;
    return;
  }
  for (int i = (0), ei = (sum); i < ei; i++) {
    if (currsum + i < sum && Cnt[i] != 0) {
      long long was = Cnt[i];
      --Cnt[i];
      rec(ind + 1, sum, currsum + i, (currcnt * was) % mod);
      ++Cnt[i];
    }
  }
}
bool check(int m, int cnt) {
  int calc = calcCnt(m, cnt);
  if (cnt == 0) --calc;
  char str[20];
  int res = 0;
  for (int i = (1), ei = (m + 1); i < ei; i++) {
    sprintf(str, "%d", i);
    int curr = 0;
    for (int j = (0), ej = (strlen(str)); j < ej; j++)
      if (str[j] == '4' || str[j] == '7') ++curr;
    res += (curr == cnt);
  }
  return calc == res;
}
void run() {
  init();
  int m;
  cin >> m;
  for (int i = (0), ei = (10); i < ei; i++) Cnt[i] = calcCnt(m, i);
  if (Cnt[0] > 0) --Cnt[0];
  res = 0;
  for (int s = (1), es = (10); s < es; s++) {
    long long curr = Cnt[s];
    rec(0, s, 0, curr);
  }
  cout << res << endl;
}
int main() {
  run();
  return 0;
}
