#include <bits/stdc++.h>
using namespace std;
template <class T>
bool checkMin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool checkMax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
string tostr(int x) {
  stringstream ss;
  ss << x;
  return ss.str();
}
const int MOD = 1000000007;
void add(long long& a, long long b) { a = (a + b) % MOD; }
void mul(long long& a, long long b) { a = (a * b) % MOD; }
long long mul1(long long a, long long b) { return (a * b) % MOD; }
const int INF = 1e9;
const int MN = -1;
int m;
string M;
int dp[15][15][2];
int ways[15];
int C[15];
long long sum, res;
int luckyWays(int x, int L, bool isless) {
  if (L < 0) return 0;
  if (x == ((int)(M).size())) return !L;
  int& ans = dp[x][L][isless];
  if (ans != -1) return ans;
  ans = 0;
  int digit = M[x] - '0';
  int n = isless ? 9 : digit;
  for (int i = 0; i <= n; i++)
    ans += luckyWays(x + 1, L - (i == 4 || i == 7), isless || (i < digit));
  return ans;
}
long long nCrK(long long n, int k) {
  long long R = 1;
  for (int i = 0; i < (k); i++) mul(R, n - i);
  return R;
}
void f(int at, int left) {
  if (left < 0) return;
  if (at == 6) {
    long long ans = 1;
    for (int i = 0; i <= 10; i++) {
      mul(ans, nCrK(ways[i], C[i]));
    }
    add(sum, ans);
    return;
  }
  long long res = 0;
  for (int i = 0; i <= left; i++) {
    if (C[i] < ways[i]) {
      C[i]++;
      f(at + 1, left - i);
      C[i]--;
    }
  }
}
int main() {
  while (scanf("%d", &m) != EOF) {
    memset(dp, -1, sizeof(dp));
    M = tostr(m);
    int l = M.length();
    sum = res = 0;
    for (int i = 0; i <= l; i++) {
      ways[i] = luckyWays(0, i, 0);
    }
    ways[0]--;
    for (int i = 1; i <= l; i++) {
      memset(C, sum = 0, sizeof(C));
      f(0, i - 1);
      add(res, sum * ways[i]);
    }
    cout << res << endl;
  }
}
