#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007LL;
long long dp1[11][10], dp2[11][10], dp3[7][10];
int decm[11];
int cnt[10] = {0};
void BF(int s, int k, int j, long long add) {
  if (j == s) {
    dp3[s][k] += add;
    dp3[s][k] %= MOD;
    return;
  }
  int q;
  for (q = 0; k + q <= 9; ++q) {
    ++cnt[q];
    BF(s, k + q, j + 1, (add * ((dp3[1][q] - cnt[q] + MOD + 1) % MOD)) % MOD);
    --cnt[q];
  }
}
int main() {
  int m;
  int l, s, k, q, i, len;
  long long ans;
  char buf[11];
  scanf("%d", &m);
  sprintf(buf, "%d", m);
  len = strlen(buf);
  for (i = 0; i < len; ++i) decm[i + 1] = buf[len - 1 - i] - '0';
  dp1[0][0] = 1;
  for (k = 1; k <= 9; ++k) dp1[0][k] = 0;
  for (l = 1; l < len; ++l) {
    dp1[l][0] = (8 * dp1[l - 1][0]) % MOD;
    for (k = 1; k <= 9; ++k)
      dp1[l][k] = (2 * dp1[l - 1][k - 1] + 8 * dp1[l - 1][k]) % MOD;
  }
  dp2[0][0] = 1;
  for (k = 1; k <= 9; ++k) dp2[0][k] = 0;
  for (l = 1; l <= len; ++l)
    for (k = 0; k <= 9; ++k) {
      dp2[l][k] = ((decm[l] - (decm[l] > 4) - (decm[l] > 7)) * dp1[l - 1][k] +
                   (decm[l] != 4 && decm[l] != 7) * dp2[l - 1][k]) %
                  MOD;
      if (k) {
        if (decm[l] > 4)
          dp2[l][k] += dp1[l - 1][k - 1];
        else if (decm[l] == 4)
          dp2[l][k] += dp2[l - 1][k - 1];
        if (decm[l] > 7)
          dp2[l][k] += dp1[l - 1][k - 1];
        else if (decm[l] == 7)
          dp2[l][k] += dp2[l - 1][k - 1];
        dp2[l][k] %= MOD;
      }
    }
  dp3[1][0] = dp2[len][0] - 1;
  for (k = 1; k <= 9; ++k) dp3[1][k] = dp2[len][k];
  BF(6, 0, 0, 1);
  for (ans = 0, k = 1; k <= 9; ++k)
    for (q = 0; q < k; ++q) {
      ans += dp3[1][k] * dp3[6][q];
      ans %= MOD;
    }
  printf("%I64d\n", ans);
  return 0;
}
