#include <bits/stdc++.h>
using namespace std;
template <typename T>
string tostr(const T& t) {
  ostringstream os;
  os << t;
  return os.str();
}
vector<int> cache[12][12];
const int mod = 1000000007;
void add(vector<int>& v, const vector<int>& w) {
  for (int i = (int)(0); i <= (int)(12 - 1); ++i) v[i] += w[i];
}
vector<int> cnt47(int digits, int already47) {
  if (digits == 0) {
    vector<int> v(12, 0);
    v[already47] = 1;
    return v;
  }
  if (!cache[digits][already47].empty()) {
    return cache[digits][already47];
  }
  vector<int> v(12, 0);
  for (int d = (int)(0); d <= (int)(10 - 1); ++d) {
    int e = (d == 4 || d == 7) ? 1 : 0;
    add(v, cnt47(digits - 1, already47 + e));
  }
  return cache[digits][already47] = v;
}
vector<int> V;
long long ways(int parties, int rem47) {
  if (parties == 0) return 1;
  long long sum = 0;
  for (int i = 0; i <= rem47 && V[i] > 0; ++i) {
    V[i] -= 1;
    sum += (V[i] + 1) * ways(parties - 1, rem47 - i);
    sum %= mod;
    V[i] += 1;
  }
  return sum;
}
int main() {
  char buf[16];
  scanf("%s", buf);
  vector<int> v(12, 0);
  int already47 = 0;
  int len = strlen(buf);
  for (int i = (int)(0); i <= (int)(len - 1); ++i) {
    int d = buf[i] - '0';
    int lim = (i + 1 == len) ? d + 1 : d;
    for (int j = (int)(0); j <= (int)(lim - 1); ++j) {
      int e = (j == 4 || j == 7) ? 1 : 0;
      add(v, cnt47(len - i - 1, already47 + e));
    }
    if (d == 4 || d == 7) {
      ++already47;
    }
  }
  v[0] -= 1;
  V = v;
  long long w = 0;
  for (int i = 1; i < 12 && v[i] > 0; ++i) {
    w += v[i] * ways(6, i - 1);
    w %= mod;
  }
  printf("%d\n", (int)(w % mod));
  return 0;
}
