#include <bits/stdc++.h>
using namespace std;
const long long N = 11;
const long long mod = 1e9 + 7;
long long dp[N][11][2];
long long m;
long long a[N];
long long dfs(long long len, long long cnt, bool limit) {
  if (len == 0) return cnt == 0;
  if (~dp[len][cnt][limit]) return dp[len][cnt][limit];
  long long up = limit ? a[len] : 9;
  long long res = 0;
  for (long long i = 0; i <= up; i++) {
    if (i == 4 || i == 7) {
      if (cnt >= 1) res += dfs(len - 1, cnt - 1, limit & (i == up));
    } else
      res += dfs(len - 1, cnt, limit & (i == up));
  }
  return dp[len][cnt][limit] = res;
}
long long cnt = 0;
void solve(long long n) {
  memset(dp, -1, sizeof dp);
  while (n) {
    a[++cnt] = n % 10;
    n /= 10;
  }
  for (long long i = 0; i <= cnt; i++) dfs(cnt, i, 1);
}
long long c(long long a, long long b) {
  if (b > a) return 0;
  long long res = 1;
  for (long long i = 0; i < b; i++) res = (a - i) % mod * res % mod;
  return res;
}
long long res = 0;
long long mp[12];
long long ans = 0;
long long ress = 1;
void dfs(long long u, long long ct, long long up) {
  if (ct >= up) return;
  if (u == 6) {
    ress = 1;
    for (long long i = 0; i <= up; i++) {
      ress = (ress * c(dp[cnt][i][1], mp[i]) % mod);
    }
    ans = (ans + ress) % mod;
    return;
  }
  for (long long i = 0; i <= up; i++) {
    mp[i]++;
    dfs(u + 1, ct + i, up);
    mp[i]--;
  }
}
signed main() {
  cin >> m;
  solve(m);
  dp[cnt][0][1]--;
  for (long long i = 1; i <= cnt; i++) {
    long long tmp = 0;
    if (dp[cnt][i][1] > 0) {
      ans = 0;
      dfs(0, 0, i);
      res = (res + dp[cnt][i][1] * ans % mod) % mod;
    }
  }
  cout << res << endl;
  return 0;
}
