#include <bits/stdc++.h>
using namespace std;
long long dp[20];
long long sum[20];
long long a[100];
long long POW(long long n, long long k) {
  if (k < 0) return 0;
  if (k == 0) return 1;
  long long res = POW(n, k / 2);
  res = (res * res) % 1000000007ll;
  if (k % 2 == 1) res = (res * n) % 1000000007ll;
  return res % 1000000007ll;
}
long long F(long long n) {
  if (n < 0) return 0;
  long long res = 1;
  for (long long i = 1; i <= n; i++) res = (res * i) % 1000000007ll;
  return res;
}
long long F(long long l, long long r) {
  if (l < 1) return 0;
  long long res = 1;
  for (long long i = l; i <= r; i++) res = (res * i) % 1000000007ll;
  return res;
}
long long Sum(long long l, long long r) {
  long long res = sum[r] - sum[l - 1];
  if (res < 0) res = 0;
  return res;
}
long long dfs(long long n, long long sum) {
  if (sum > 10) return 0;
  if (n > 6) return Sum(sum + 1, 10);
  long long res = 0;
  for (int i = 0; i <= 10; i++)
    if (dp[i] > 0) {
      dp[i]--;
      res += (dp[i] + 1) * dfs(n + 1, sum + i);
      res = res % 1000000007ll;
      dp[i]++;
    }
  return res;
}
int main() {
  long long n;
  cin >> n;
  long long x = n;
  int m = 0;
  while (x) {
    a[m++] = x % 10;
    x /= 10;
  }
  dp[0] = 0;
  long long ans = 0;
  for (long long i = 0; i <= 10; i++) {
    long long cnt = 0;
    for (long long x = 0; x <= i; x++) {
      long long y = i - x;
      long long xx = x, yy = y;
      for (long long j = 10; j >= 0; j--) {
        if (xx < 0 || yy < 0) break;
        int mul = a[j];
        if (a[j] > 4) mul--;
        if (a[j] > 7) mul--;
        if (j - (xx + yy) >= 0) {
          cnt += mul * POW(8, j - (xx + yy)) *
                 (F(j) / F(xx) / F(yy) / F(j - (xx + yy)));
          cnt = cnt % 1000000007ll;
        }
        if (a[j] > 4) {
          xx--;
          mul = 1;
          if (xx >= 0)
            if (j - (xx + yy) >= 0) {
              cnt += mul * POW(8, j - (xx + yy)) *
                     (F(j) / F(xx) / F(yy) / F(j - (xx + yy)));
              cnt = cnt % 1000000007ll;
            }
          xx++;
        }
        if (a[j] > 7) {
          yy--;
          mul = 1;
          if (yy >= 0)
            if (j - (xx + yy) >= 0) {
              cnt += mul * POW(8, j - (xx + yy)) *
                     (F(j) / F(xx) / F(yy) / F(j - (xx + yy)));
              cnt = cnt % 1000000007ll;
            }
          yy++;
        }
        cnt = cnt % 1000000007ll;
        if (a[j] == 4) xx--;
        if (a[j] == 7) yy--;
      }
      xx = x;
      yy = y;
      for (long long j = 10; j >= 0; j--) {
        if (a[j] == 4) xx--;
        if (a[j] == 7) yy--;
      }
      if (xx == 0 && yy == 0) cnt++;
    }
    if (i == 0) cnt--;
    dp[i] = cnt;
  }
  sum[0] = dp[0];
  for (int i = 1; i <= 10; i++) sum[i] = sum[i - 1] + dp[i];
  ans = dfs(1, 0);
  cout << ans;
  return 0;
}
