#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long lucky[10], C[10][10], tmp[10], ans, tot;
void count_lucky(int free_digit, int extra) {
  tmp[0] = pow(8, free_digit);
  for (int i = 1; i <= free_digit; i++)
    tmp[i] = C[free_digit][i] * (1LL << i) * pow(8, free_digit - i);
  for (int i = 0; i + extra <= 9; i++) lucky[i + extra] += tmp[i];
}
char s[15];
int digit[15], limit;
void dfs(int sum, int idx, long long ways) {
  if (idx == 7) {
    tot = (tot + ways) % mod;
  } else {
    for (int i = 0; i + sum < limit; i++) {
      if (lucky[i] == 0) return;
      lucky[i]--;
      dfs(sum + i, idx + 1, ways * (lucky[i] + 1) % mod);
      lucky[i]++;
    }
  }
}
int main() {
  C[0][0] = 1;
  for (int i = 1; i <= 9; i++) {
    C[i][0] = 1;
    for (int j = 1; j <= i; j++) C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
  }
  scanf("%s", s + 1);
  int n = strlen(s + 1), extra = 0;
  for (int i = 1; i <= n; i++) {
    digit[i] = s[i] - '0';
    for (int j = 0; j < digit[i]; j++) {
      count_lucky(n - i, extra + (j == 4 || j == 7));
    }
    if (i == n) count_lucky(n - i, extra + (digit[i] == 4 || digit[i] == 7));
    if (digit[i] == 4 || digit[i] == 7) extra++;
    memset(tmp, 0, sizeof tmp);
  }
  lucky[0]--;
  for (int i = 1; i <= 9; i++) {
    tot = 0;
    limit = i;
    dfs(0, 1, 1);
    ans = (ans + tot * lucky[i] % mod) % mod;
  }
  printf("%lld\n", ans);
  return 0;
}
