#include <bits/stdc++.h>
using namespace std;
long long base = 1000000007;
int m, mm, sz;
long long dp[20][20][2];
int mr[20];
long long A(int x, int y) {
  long long ans = 1;
  for (long long i = x; i >= x - y + 1; i--) {
    ans = ans * i;
    ans %= base;
  }
  return ans;
}
long long bin(long long x, long long y) {
  if (y == 0) return 1;
  long long u = bin(x, y / 2);
  if (y % 2 == 0) {
    return u * u % base;
  } else {
    return u * u % base * x % base;
  }
}
long long C(int x, int y) {
  long long ans = 1;
  for (long long i = x; i >= x - y + 1; i--) ans = ans * i, ans %= base;
  for (int i = 1; i <= y; i++) ans = ans * bin(i, base - 2), ans %= base;
  return ans;
}
long long f[30][30][30];
long long glans = 0;
long long pr[100];
int pr2[100];
int main() {
  cin >> m;
  mm = m;
  while (mm > 0) {
    sz++;
    mm /= 10;
  }
  mm = m;
  for (int i = sz; i > 0; i--) {
    mr[i] = mm % 10;
    mm /= 10;
  }
  dp[0][0][1] = 1;
  for (int i = 0; i < sz; i++) {
    for (int j = 0; j <= 12; j++) {
      for (int z = 0; z < 2; z++) {
        for (int next = 0; next < 10; next++) {
          if (z == 0) {
            if (next != 4 && next != 7) {
              dp[i + 1][j][z] += dp[i][j][z];
            } else {
              dp[i + 1][j + 1][z] += dp[i][j][z];
            }
          } else {
            if (next == mr[i + 1]) {
              if (next == 4 || next == 7) {
                dp[i + 1][j + 1][z] += dp[i][j][z];
              } else {
                dp[i + 1][j][z] += dp[i][j][z];
              }
            }
            if (next < mr[i + 1]) {
              if (next == 4 || next == 7) {
                dp[i + 1][j + 1][0] += dp[i][j][z];
              } else {
                dp[i + 1][j][0] += dp[i][j][z];
              }
            }
          }
        }
      }
    }
  }
  for (int i = 0; i <= sz; i++) pr[i] = (dp[sz][i][0] + dp[sz][i][1]) % base;
  pr[0]--;
  for (int i = 0; i <= 6; i++) f[0][i][0] = C(pr[0], i);
  for (int i = 1; i <= sz; i++) {
    f[i][0][0] = 1;
    for (int j = 1; j <= 6; j++) {
      for (int z = 0; z <= sz; z++) {
        for (int e = 0; e <= j && e * i <= z; e++) {
          f[i][j][z] += f[i - 1][j - e][z - e * i] * C(pr[i], e);
          f[i][j][z] %= base;
        }
      }
    }
  }
  for (int i = 0; i <= sz; i++) {
    long long zz = 720;
    long long ee = f[sz][6][i] * zz;
    ee %= base;
    for (int j = i + 1; j <= sz; j++) {
      glans = glans + ee * pr[j];
      glans %= base;
    }
  }
  cout << glans << endl;
  return 0;
}
