#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const int N = 11;
int dp[N][N], cnt[N * 2];
void pre() {
  memset(dp, 0, sizeof(dp));
  dp[0][0] = 1;
  for (int n = 1; n < N; n++) {
    for (int k = 0; k < N; k++) {
      dp[n][k] = 8 * dp[n - 1][k];
      if (k != 0) dp[n][k] += 2 * dp[n - 1][k - 1];
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout << setprecision(32);
  pre();
  long long m;
  cin >> m;
  vector<int> dig;
  {
    long long n = m;
    while (n) {
      dig.push_back(n % 10);
      n /= 10;
    }
    reverse(dig.begin(), dig.end());
  }
  memset(cnt, 0, sizeof(cnt));
  int n = dig.size();
  int prev = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < dig[i]; j++) {
      for (int k = 0; k < N; k++) {
        if (j == 4 || j == 7)
          cnt[prev + k + 1] += dp[n - 1 - i][k];
        else
          cnt[prev + k] += dp[n - 1 - i][k];
      }
    }
    if (dig[i] == 4 || dig[i] == 7) prev++;
  }
  cnt[prev]++;
  cnt[0]--;
  long long ans = 0;
  int i[6];
  for (i[0] = 0; i[0] < N; i[0]++) {
    for (i[1] = 0; i[1] < N; i[1]++) {
      if (i[0] + i[1] >= N) break;
      for (i[2] = 0; i[2] < N; i[2]++) {
        if (i[0] + i[1] + i[2] >= N) break;
        for (i[3] = 0; i[3] < N; i[3]++) {
          if (i[0] + i[1] + i[2] + i[3] >= N) break;
          for (i[4] = 0; i[4] < N; i[4]++) {
            if (i[0] + i[1] + i[2] + i[3] + i[4] >= N) break;
            for (i[5] = 0; i[5] < N; i[5]++) {
              int sum;
              if ((sum = i[0] + i[1] + i[2] + i[3] + i[4] + i[5]) >= N) break;
              map<int, int> mp;
              for (int j = 0; j < 6; j++) {
                mp[i[j]]++;
              }
              long long tmp = 0;
              for (int j = sum + 1; j < N; j++) {
                tmp += cnt[j];
              }
              for (auto x : mp) {
                for (int j = 0; j < x.second; j++) {
                  (tmp *= (cnt[x.first] - j)) %= mod;
                }
              }
              ans += tmp;
              if (ans >= mod) ans -= mod;
            }
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
