#include <bits/stdc++.h>
using namespace std;
long long dp[12][12];
long long MOD = 1000000007;
long long has[10];
int digit[10];
int n;
long long other = 0;
long long bear;
void init() {
  memset(dp, 0, sizeof(dp));
  dp[0][0] = 1;
  for (int i = 1; i <= 10; i++) {
    for (int j = 0; j <= i; j++) {
      if (j == 0)
        dp[i][j] = dp[i - 1][j] * 8 % MOD;
      else
        dp[i][j] = (dp[i - 1][j] * 8 % MOD + dp[i - 1][j - 1] * 2 % MOD) % MOD;
    }
  }
}
void dfs(int round, long long left, long long ways) {
  if (left < 0) return;
  if (round == 6) {
    other = (other + ways) % MOD;
    return;
  }
  for (int j = 0; j <= left; j++) {
    has[j]--;
    dfs(round + 1, left - j, (ways * (has[j] + 1)) % MOD);
    has[j]++;
  }
}
int main() {
  long long m;
  init();
  cin >> m;
  m++;
  long long tm = m;
  while (tm) {
    digit[++n] = tm % 10;
    tm /= 10;
  }
  int c = 0;
  memset(has, 0, sizeof(has));
  for (int i = n; i >= 1; i--) {
    for (int j = 0; j < i; j++) {
      if (digit[i] > 7) {
        has[j + c + 1] += dp[i - 1][j] * 2;
        has[j + c] += dp[i - 1][j] * (digit[i] - 2);
      } else if (digit[i] > 4) {
        has[j + c] += dp[i - 1][j] * (digit[i] - 1);
        has[j + c + 1] += dp[i - 1][j];
      } else {
        has[j + c] += dp[i - 1][j] * digit[i];
      }
    }
    if (digit[i] == 4 || digit[i] == 7) {
      c++;
    }
  }
  if (c) {
  }
  has[0]--;
  long long ans = 0;
  for (int j = 1; j <= n; j++) {
    if (has[j] == 0) break;
    bear = has[j];
    has[j]--;
    dfs(0, j - 1, 1);
    ans = (ans + (bear * other) % MOD) % MOD;
    other = 0;
    has[j]++;
  }
  cout << ans << endl;
  return 0;
}
