#include <bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
long long dp[12][12], cnt[12], ans, n, cntd, dig[12], dpans[12][12];
void solve() {
  int cntlucky = 0;
  for (int i = cntd; i >= 1; i--) {
    for (int j = 0; j <= cntd; j++) {
      if (dig[i] <= 4)
        dpans[cntd][j] += (j - cntlucky >= 0 ? (dig[i] - 1 + (i != cntd)) *
                                                   dp[i - 1][j - cntlucky]
                                             : 0);
      else if (dig[i] <= 7)
        dpans[cntd][j] +=
            (j - 1 - cntlucky >= 0 ? dp[i - 1][j - 1 - cntlucky] : 0) +
            (j - cntlucky >= 0
                 ? (dig[i] - 2 + (i != cntd)) * dp[i - 1][j - cntlucky]
                 : 0);
      else if (dig[i] > 7)
        dpans[cntd][j] +=
            (j - 1 - cntlucky >= 0 ? 2 * dp[i - 1][j - 1 - cntlucky] : 0) +
            (j - cntlucky >= 0
                 ? (dig[i] - 3 + (i != cntd)) * dp[i - 1][j - cntlucky]
                 : 0);
    }
    if (dig[i] == 4 || dig[i] == 7) cntlucky++;
  }
  dpans[cntd][cntlucky] += 1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  int tmp = n;
  while (tmp) {
    cntd++;
    dig[cntd] = (tmp % 10);
    tmp /= 10;
  }
  dp[0][0] = dpans[0][0] = 1;
  for (int i = 1; i < cntd; i++)
    for (int j = 0; j <= i; j++) {
      dp[i][j] = 8 * dp[i - 1][j] + 2 * dp[i - 1][j - 1];
      dpans[i][j] = 7 * dp[i - 1][j] + 2 * dp[i - 1][j - 1];
    }
  solve();
  for (int i = 1; i <= cntd; i++)
    for (int j = 0; j <= i; j++) {
      cnt[j] += dpans[i][j];
    }
  for (int i = 1; i <= cntd; i++)
    for (int j1 = 0; j1 < i; j1++)
      for (int j2 = 0; j2 + j1 < i; j2++)
        for (int j3 = 0; j3 + j2 + j1 < i; j3++)
          for (int j4 = 0; j4 + j3 + j2 + j1 < i; j4++)
            for (int j5 = 0; j5 + j4 + j3 + j2 + j1 < i; j5++)
              for (int j6 = 0; j6 + j5 + j4 + j3 + j2 + j1 < i; j6++) {
                long long tmp = ((((((cnt[j1]--) * (cnt[j2]--)) % M) *
                                   (((cnt[j3]--) * (cnt[j4]--)) % M)) %
                                  M) *
                                 (((cnt[j5]--) * (cnt[j6]--)) % M)) %
                                M;
                tmp = (tmp * cnt[i]) % M;
                ans = (ans + tmp) % M;
                cnt[j1]++;
                cnt[j2]++;
                cnt[j3]++;
                cnt[j4]++;
                cnt[j5]++;
                cnt[j6]++;
              }
  cout << ans;
  return 0;
}
