#include <bits/stdc++.h>
using namespace std;
int dp[15][15][15];
int num[15];
int bit[15];
int n, t;
long long powMod(long long a, long long b) {
  long long ret = 1;
  while (b) {
    if (b & 1) ret = (ret * a) % 1000000007;
    a = (a * a) % 1000000007;
    b >>= 1;
  }
  return ret;
}
long long A(int n, int m) {
  long long ret = 1;
  for (int i = n; i >= n - m + 1; i--) {
    ret = (ret * i) % 1000000007;
  }
  return ret;
}
long long C(int n, int m) {
  long long ret = A(n, m);
  long long temp = 1;
  for (int i = 1; i <= m; i++) temp = (temp * i) % 1000000007;
  return ret * powMod(temp, 1000000007 - 2) % 1000000007;
}
int dfs1(int cur, int last, int sum, bool flag) {
  if (!cur) {
    if (last == sum) return 1;
    return 0;
  }
  if (last > sum) return 0;
  if (!flag && dp[cur][last][sum] != -1) return dp[cur][last][sum];
  int maxm = flag ? bit[cur] : 9;
  int ret = 0;
  for (int i = 0; i <= maxm; i++) {
    if (i == 4 || i == 7)
      ret += dfs1(cur - 1, last + 1, sum, flag && i == maxm);
    else
      ret += dfs1(cur - 1, last, sum, flag && i == maxm);
  }
  if (!flag) dp[cur][last][sum] = ret;
  return ret;
}
void getBit() {
  t = 0;
  while (n) {
    bit[++t] = n % 10;
    n /= 10;
  }
  for (int i = 0; i <= 9; i++) num[i] = dfs1(t, 0, i, 1);
  num[0]--;
  return;
}
long long dfs2(int n, int sum, int p) {
  if (p == 0) return A(6, 6);
  if (n < 0) return 0;
  long long ret = 0;
  for (int i = 0; i <= num[n] && i * n < sum && i <= p; i++) {
    ret = (ret + C(num[n], i) * dfs2(n - 1, sum - i * n, p - i) % 1000000007) %
          1000000007;
  }
  return ret;
}
int main() {
  while (scanf("%d", &n) != EOF) {
    memset(dp, -1, sizeof(dp));
    memset(num, 0, sizeof(num));
    getBit();
    long long ans = 0;
    for (int i = 1; i <= 9; i++) {
      ans = (ans + 1LL * num[i] * dfs2(i - 1, i, 6) % 1000000007) % 1000000007;
    }
    printf("%I64d\n", ans);
  }
  return 0;
}
