#include <bits/stdc++.h>
using namespace std;
vector<int> dig;
int cnt[13];
void getDig(int m) {
  if (m > 9) getDig(m / 10);
  dig.push_back(m % 10);
}
long long mod = 1000000007, ans, dp[13][13];
long long An6(int n) {
  if (n < 6) return 0LL;
  long long mu = 1;
  for (int i = 1; i <= 6; ++i) mu = (mu * (n - i + 1)) % mod;
  return mu;
}
int pow(int a, int n) {
  int r = 1;
  while (n) {
    if (n & 1) r *= a;
    a *= a;
    n >>= 1;
  }
  return r;
}
int C[111][111];
long long c1[11];
long long df;
int lim;
void dfs(int dep, int sum, long long v) {
  if (sum > lim) return;
  if (dep == 6) {
    df = (df + v) % mod;
    return;
  }
  for (int i = 0; i + sum < lim; ++i) {
    if (c1[i]) {
      long long v1 = (v * c1[i]) % mod;
      --c1[i];
      dfs(dep + 1, sum + i, v1);
      ++c1[i];
    }
  }
}
int main() {
  int m, i, j, k, len;
  for (i = 0; i < 100; ++i) {
    C[i][0] = 1;
    for (j = 1; j <= i; ++j) C[i][j] = C[i - 1][j] + C[i - 1][j - 1];
  }
  while (scanf("%d", &m) != EOF) {
    memset(dp, 0, sizeof(dp));
    memset(cnt, 0, sizeof(cnt));
    ++m;
    dig.clear();
    getDig(m);
    len = dig.size();
    dp[1][0] = 7;
    dp[1][1] = 2;
    for (i = 2; i < len; ++i) {
      for (j = 0; j <= 9; ++j) {
        for (k = 0; k < i; ++k) {
          dp[i][k + (j == 4 || j == 7)] += dp[i - 1][k];
        }
      }
    }
    for (i = 1; i < len; ++i) {
      for (j = 1; j <= i; ++j) {
        cnt[j] += dp[i][j];
      }
    }
    int now = 0;
    for (i = 0; i < len; ++i) {
      for (j = (i == 0 ? 1 : 0); j < dig[i]; ++j) {
        for (k = 0; k + i < len; ++k) {
          cnt[k + now + (j == 4 || j == 7)] +=
              pow(2, k) * pow(8, len - i - 1 - k) * C[len - i - 1][k];
        }
      }
      now += (j == 4 || j == 7);
    }
    int sum = 0;
    ans = 0;
    cnt[0] = m - 1;
    for (i = 1; i < 11; ++i) cnt[0] -= cnt[i];
    for (i = 0; i < 11; ++i) {
      for (j = 0; j < 11; ++j) c1[i] = cnt[i];
      df = 0;
      lim = i;
      dfs(0, 0, 1LL);
      ans = (ans + 1LL * df * cnt[i]) % mod;
      sum += cnt[i];
    }
    printf("%I64d\n", ans);
  }
  return 0;
}
