#include <bits/stdc++.h>
using namespace std;
int const MX = 10;
long long const MODULE = 1000000007LL;
int ms[100];
long long real_cnt[100];
long long ans = 0;
long long A(long long n, long long k) {
  if (n < k) return 0;
  long long ans = 1;
  for (long long i = n; i > n - k; i--) ans = (ans * i) % MODULE;
  return ans % MODULE;
}
long long rec(char *st, int from, int n, int c4, int c7, int is_eq) {
  int rem = n - from;
  if (c4 + c7 > rem) return 0;
  if (from >= n) return 1;
  long long ans = 0;
  int ch = st[from] - '0';
  if (is_eq) {
    int cnt_other = 0;
    int cnt_4 = 0;
    int cnt_7 = 0;
    for (int i = 0; i < ch; i++)
      if (i != 4 && i != 7)
        cnt_other++;
      else if (i == 4)
        cnt_4++;
      else if (i == 7)
        cnt_7++;
    ans += cnt_other * rec(st, from + 1, n, c4, c7, 0);
    if (c4) ans += cnt_4 * rec(st, from + 1, n, c4 - cnt_4, c7, 0);
    if (c7) ans += cnt_7 * rec(st, from + 1, n, c4, c7 - cnt_7, 0);
    if (ch == 4) {
      if (c4) ans += rec(st, from + 1, n, c4 - 1, c7, 1);
    } else if (ch == 7) {
      if (c7) ans += rec(st, from + 1, n, c4, c7 - 1, 1);
    } else
      ans += rec(st, from + 1, n, c4, c7, 1);
  } else {
    int cnt_other = 0;
    int cnt_4 = 0;
    int cnt_7 = 0;
    for (int i = 0; i <= 9; i++)
      if (i != 4 && i != 7)
        cnt_other++;
      else if (i == 4)
        cnt_4++;
      else if (i == 7)
        cnt_7++;
    ans += cnt_other * rec(st, from + 1, n, c4, c7, 0);
    if (c4) ans += cnt_4 * rec(st, from + 1, n, c4 - cnt_4, c7, 0);
    if (c7) ans += cnt_7 * rec(st, from + 1, n, c4, c7 - cnt_7, 0);
  }
  return ans;
}
long long calc(int x, int c4, int c7) {
  char st[100];
  sprintf(st, "%d", x);
  int n = (int)strlen(st);
  long long d = rec(st, 0, n, c4, c7, 1);
  return d - (c4 + c7 == 0);
}
int slow_calc(int x, int c4, int c7) {
  int ans = 0;
  for (int i = 1; i <= x; i++) {
    int y = i;
    int cur_4 = 0, cur_7 = 0;
    while (y) {
      cur_4 += (y % 10) == 4;
      cur_7 += (y % 10) == 7;
      y /= 10;
    }
    if (cur_4 == c4 && cur_7 == c7) ans++;
  }
  return ans;
}
int main() {
  int m;
  scanf("%d", &m);
  for (int c4 = 0; c4 <= MX; c4++)
    for (int c7 = 0; c7 <= MX; c7++) real_cnt[c4 + c7] += calc(m, c4, c7);
  for (int cnt = 0; cnt <= MX; cnt++)
    for (int a = 0; a <= MX && a < cnt; a++)
      for (int b = 0; b <= MX && a + b < cnt; b++)
        for (int c = 0; c <= MX && a + b + c < cnt; c++)
          for (int d = 0; d <= MX && a + b + c + d < cnt; d++)
            for (int e = 0; e <= MX && a + b + c + d + e < cnt; e++)
              for (int q = 0; q <= MX && a + b + c + d + e + q < cnt; q++) {
                for (int i = 0; i <= MX; i++) ms[i] = 0;
                ms[cnt]++;
                ms[a]++;
                ms[b]++;
                ms[c]++;
                ms[d]++;
                ms[e]++;
                ms[q]++;
                long long g = 1;
                for (int i = 0; i <= MX; i++)
                  g = (g * A(real_cnt[i], ms[i])) % MODULE;
                ans = (ans + g) % MODULE;
              }
  cout << ans;
  return 0;
}
