#include <bits/stdc++.h>
using namespace std;
const int P = 1e9 + 7;
int m, cnt[11];
int num[11], len;
int dp[11][11][2];
int dfs(int x, int Num, bool fl, int k) {
  if (x == 0) return Num == k;
  if (dp[x][Num][fl] != -1) return dp[x][Num][fl];
  int res = 0;
  int up = fl ? 9 : num[x];
  for (int i = 0; i <= up; i++)
    res = (res + dfs(x - 1, ((i == 4) || (i == 7)) ? Num + 1 : Num,
                     fl | (i != up), k)) %
          P;
  dp[x][Num][fl] = res;
  return res;
}
int DFS(int la, int x) {
  if (la <= 0) return 0;
  if (x == 7) return 1;
  int res = 0;
  for (int i = 0; i < la; i++) {
    if (cnt[i] == 0) continue;
    cnt[i]--;
    res = (res + (cnt[i] + 1) * 1ll * DFS(la - i, x + 1)) % P;
    cnt[i]++;
  }
  return res;
}
int main() {
  scanf("%d", &m);
  while (m) {
    num[++len] = m % 10;
    m /= 10;
  }
  for (int i = 0; i <= 9; i++) {
    memset(dp, -1, sizeof(dp));
    cnt[i] = dfs(len, 0, 0, i);
  }
  cnt[0]--;
  int ans = 0;
  for (int i = 0; i <= 9; i++) {
    cnt[i]--;
    ans = (ans + (cnt[i] + 1) * 1ll * DFS(i, 1)) % P;
    cnt[i]++;
  }
  printf("%d\n", ans);
}
