#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000 * 1000 * 1000 + 7;
string a;
int N;
int cache[12][12][2];
int total_ways[12];
int myPow[12];
int c[12];
int add(int a, int b) { return (a + b) % MOD; }
int mul(int a, int b) { return (a * 1LL * b) % MOD; }
int dp(int i, int t, int lw) {
  if (cache[i][t][lw] != -1) return cache[i][t][lw];
  int &ans = cache[i][t][lw] = 0;
  if (lw) {
    if (t == 0) return ans = myPow[N - i];
    if (i >= N) return ans = 0;
    ans += 8 * dp(i + 1, t, lw);
    ans += 2 * dp(i + 1, t - 1, lw);
  } else {
    if (i == N && t == 0) return ans = 1;
    if (t == 0) {
      ans += c[a[i] - '0'] * dp(i + 1, t, 1);
      if (a[i] != '4' && a[i] != '7') ans += dp(i + 1, t, 0);
      return ans;
    }
    if (i >= N) return ans = 0;
    if (a[i] > '7') ans += dp(i + 1, t - 1, 1);
    if (a[i] == '7') ans += dp(i + 1, t - 1, 0);
    if (a[i] > '4') ans += dp(i + 1, t - 1, 1);
    if (a[i] == '4') ans += dp(i + 1, t - 1, 0);
    ans += c[a[i] - '0'] * dp(i + 1, t, 1);
    if (a[i] != '7' && a[i] != '4') ans += dp(i + 1, t, 0);
  }
  return ans;
}
int getSum(int n, int t) {
  if (t < 0) return 0;
  if (n == 0) return 1;
  int ans = 0;
  for (int i = 0; i <= t; i++) {
    int tmp = total_ways[i]--;
    ans = add(ans, mul(tmp, getSum(n - 1, t - i)));
    total_ways[i]++;
  }
  return ans;
}
int main() {
  int m;
  cin >> m;
  stringstream ss;
  ss << m;
  ss >> a;
  N = ((int)(a).size());
  c[0] = 0;
  for (int i = 1; i <= 9; ++i) {
    c[i] = c[i - 1];
    if (i - 1 != 4 && i - 1 != 7) c[i]++;
  }
  myPow[0] = 1;
  for (int i = 1; i < 12; ++i) {
    myPow[i] = myPow[i - 1] * 8;
  }
  memset(cache, -1, sizeof cache);
  for (int i = 0; i <= N; i++) total_ways[i] = dp(0, i, 0);
  total_ways[0]--;
  int sum = 0;
  for (int i = 1; i <= N; ++i) {
    int ways = dp(0, i, 0);
    sum = add(sum, mul(ways, getSum(6, i - 1)));
  }
  cout << sum << endl;
  return 0;
}
