#include <bits/stdc++.h>
using namespace std;
const int mx = 20, MX = 1e6;
const long long mod = 1e9 + 7;
int n;
long long lucky[mx], cur[mx][mx][2], ans;
long long calc(int ind, int cnt, int stat, string &s, int fin) {
  if (ind >= n) {
    if (cnt != fin)
      return 0;
    else
      return 1;
  }
  if (cur[ind][cnt][stat] >= 0) return cur[ind][cnt][stat];
  int mxx = s[ind] - '0', cr = s[ind] - '0';
  long long tot = 0;
  if (stat) mxx = 9;
  for (int i = 0; i <= mxx; ++i) {
    int add = ((i == 4) || (i == 7));
    if (i >= cr) {
      tot = (tot + calc(ind + 1, cnt + add, stat, s, fin)) % mod;
    } else {
      tot = (tot + calc(ind + 1, cnt + add, 1, s, fin)) % mod;
    }
  }
  cur[ind][cnt][stat] = tot;
  return tot;
}
int main() {
  int m;
  scanf("%d", &m);
  string M = to_string(m);
  n = M.size();
  for (int i = 0; i < mx; ++i) {
    for (int i = 0; i < mx; ++i) {
      for (int j = 0; j < mx; ++j) {
        cur[i][j][0] = -1;
        cur[i][j][1] = -1;
      }
    }
    lucky[i] = calc(0, 0, 0, M, i);
  }
  --lucky[0];
  for (int i = 0; i < MX; ++i) {
    int num = i, total = 0, used[10] = {0};
    while (num) {
      ++used[num % 10];
      ++total;
      num /= 10;
    }
    used[0] += (6 - total);
    long long add = 1, sum = 0;
    for (int j = 0; j < 10; ++j) {
      sum += (used[j] * j);
    }
    if (sum > 10) continue;
    for (int j = 0; j < 10; ++j) {
      if (used[j] > lucky[j]) {
        add = 0;
        break;
      }
      for (int k = 0; k < used[j]; ++k) {
        add = (add * (lucky[j] - k)) % mod;
      }
    }
    for (long long j = sum + 1; j < 10; ++j) {
      ans = (ans + (add * lucky[j]) % mod) % mod;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
