#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int MOD = (int)1e9 + 7;
int cnt[11], m, d[11], len;
int dp[11][11][2];
int dfs(int pos, int ost, int lower) {
  if (ost < 0) return 0;
  if (pos == -1) {
    if (ost == 0) return 1;
    return 0;
  } else {
    int &res = dp[pos][ost][lower];
    if (res != -1) return res;
    res = 0;
    if (lower) {
      res += 2 * dfs(pos - 1, ost - 1, lower);
      res += 8 * dfs(pos - 1, ost, lower);
    } else {
      for (int i = 0; i < d[pos]; i++) {
        if (i == 4 || i == 7)
          res += dfs(pos - 1, ost - 1, 1);
        else
          res += dfs(pos - 1, ost, 1);
      }
      if (d[pos] == 4 || d[pos] == 7)
        res += dfs(pos - 1, ost - 1, 0);
      else
        res += dfs(pos - 1, ost, 0);
    }
    return res;
  }
}
int num[8];
int main() {
  memset(dp, -1, sizeof(dp));
  cin >> m;
  len = 0;
  while (m > 0) {
    d[len++] = m % 10;
    m /= 10;
  }
  for (int i = len; i >= 0; i--) {
    cnt[i] = dfs(len - 1, i, 0);
  }
  cnt[0]--;
  int res = 0;
  for (int i = 1; i <= len; i++) {
    int cur = cnt[i];
    for (num[0] = 0; num[0] < i; num[0]++) {
      if (cnt[num[0]] <= 0) continue;
      int cur1 = (long long)cur * cnt[num[0]] % MOD;
      cnt[num[0]]--;
      for (num[1] = 0; num[0] + num[1] < i; num[1]++) {
        if (cnt[num[1]] <= 0) continue;
        int cur2 = (long long)cur1 * cnt[num[1]] % MOD;
        cnt[num[1]]--;
        for (num[2] = 0; num[0] + num[1] + num[2] < i; num[2]++) {
          if (cnt[num[2]] <= 0) continue;
          int cur3 = (long long)cur2 * cnt[num[2]] % MOD;
          cnt[num[2]]--;
          for (num[3] = 0; num[0] + num[1] + num[2] + num[3] < i; num[3]++) {
            if (cnt[num[3]] <= 0) continue;
            int cur4 = (long long)cur3 * cnt[num[3]] % MOD;
            cnt[num[3]]--;
            for (num[4] = 0; num[0] + num[1] + num[2] + num[3] + num[4] < i;
                 num[4]++) {
              if (cnt[num[4]] <= 0) continue;
              int cur5 = (long long)cur4 * cnt[num[4]] % MOD;
              cnt[num[4]]--;
              for (num[5] = 0;
                   num[0] + num[1] + num[2] + num[3] + num[4] + num[5] < i;
                   num[5]++) {
                if (cnt[num[5]] <= 0) continue;
                int cur6 = (long long)cur5 * cnt[num[5]] % MOD;
                res = (res + cur6) % MOD;
              }
              cnt[num[4]]++;
            }
            cnt[num[3]]++;
          }
          cnt[num[2]]++;
        }
        cnt[num[1]]++;
      }
      cnt[num[0]]++;
    }
  }
  cout << res << endl;
  return 0;
}
