#include <bits/stdc++.h>
using namespace std;
int dp[15][15];
int gcnt[10];
void init() {
  int i, j, n;
  dp[1][1] = 2;
  dp[1][0] = 8;
  for (i = 2; i <= 10; i++) {
    dp[i][0] = dp[i - 1][0] * 8;
    for (j = 1; j <= 10; j++) {
      dp[i][j] = dp[i - 1][j - 1] * 2 + dp[i - 1][j] * 8;
    }
  }
}
int bit[13];
int getsize(int n) {
  int w, m = 0, i, j, k, ct = 0;
  for (w = n; w; w /= 10) bit[++m] = w % 10;
  int lef;
  for (i = m; i > 1; i--) {
    lef = i - 1;
    for (j = 0; j < bit[i]; j++) {
      for (k = 0; k <= lef; k++) {
        gcnt[ct + k + (j == 4 || j == 7)] += dp[lef][k];
      }
    }
    if (bit[i] == 4 || bit[i] == 7) {
      ct++;
    }
  }
  for (i = 0; i <= bit[1]; i++) {
    if (i == 4 || i == 7)
      gcnt[ct + 1]++;
    else
      gcnt[ct]++;
  }
  gcnt[0]--;
  return m;
}
long long getcnt(int n, int x) {
  if (n < x) return 0ul;
  long long ret = 1;
  long long now = n;
  int i, c = x;
  for (i = 0; i < x; i++) {
    ret = (ret * (n - i)) % 1000000007;
  }
  return ret;
}
long long gans;
void dfs(int lefcnt, int leflucky, int k, long long now) {
  if (k == 0 || lefcnt == 0) {
    {
      now *= getcnt(gcnt[k], lefcnt);
      now %= 1000000007;
      gans += now;
      gans %= 1000000007;
    }
    return;
  }
  int i;
  int ct1 = 1, ct2 = 1;
  for (i = 0; i * k <= leflucky && i <= lefcnt; i++) {
    ct1 = getcnt(lefcnt, i);
    ct2 = getcnt(i, i);
    dfs(lefcnt - i, leflucky - i * k, k - 1,
        (((now * getcnt(gcnt[k], i) % 1000000007) * ct1) / ct2) % 1000000007);
  }
}
int main() {
  init();
  int m, i;
  int s;
  cin >> m;
  s = getsize(m);
  for (i = s; i > 0; i--) {
    if (gcnt[i]) dfs(6, i - 1, i - 1, gcnt[i]);
  }
  cout << gans << endl;
}
