#include <bits/stdc++.h>
using namespace std;
int m, num[20], len = 0;
long long f[15], base = 1;
bool vis[20][20];
struct node {
  int num[15];
  node() { memset(num, 0, sizeof(num)); }
} dp[20][20];
node dfs(int L, int rest, bool F) {
  node cnt;
  if (L == 0) {
    cnt.num[rest]++;
    return cnt;
  }
  if (!F && vis[L][rest]) return dp[L][rest];
  int R;
  R = F ? num[L] : 9;
  for (int i = 0; i <= R; i++) {
    if (i == 4 || i == 7) {
      node sum = dfs(L - 1, rest + 1, F & (i == R));
      for (int j = 1; j <= 12; j++) {
        cnt.num[j] += sum.num[j];
      }
    } else {
      node sum = dfs(L - 1, rest, F & (i == R));
      for (int j = 1; j <= 12; j++) {
        cnt.num[j] += sum.num[j];
      }
    }
  }
  if (!F) {
    vis[L][rest] = 1;
    dp[L][rest] = cnt;
  }
  return cnt;
}
node solve(int x) {
  while (x) {
    num[++len] = x % 10;
    x /= 10;
  }
  return dfs(len, 0, 1);
}
long long anns = 0;
node sum;
void dfs(int L, long long cnt, long long maxans, int mx) {
  if (cnt >= mx) return;
  if (L == 6) {
    anns = (anns + maxans) % 1000000007;
    return;
  }
  for (int i = 0; i < mx; i++) {
    if (sum.num[i] == 0) continue;
    sum.num[i]--;
    dfs(L + 1, cnt + i, maxans * (sum.num[i] + 1) % 1000000007, mx);
    sum.num[i]++;
  }
}
int main() {
  scanf("%d", &m);
  sum = solve(m);
  for (int i = 1; i <= 10; i++) {
    f[i] = f[i - 1] + sum.num[i] * 1ll;
  }
  long long tot = m * 1ll - f[10];
  long long ans = 0;
  sum.num[0] = tot;
  for (int i = 1; i <= 10; i++) {
    if (sum.num[i] != 0) {
      anns = 0;
      dfs(0, 0, 1, i);
      ans += anns * sum.num[i];
      ans %= 1000000007;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
