#include <bits/stdc++.h>
using namespace std;
long long f[11][2][11];
long long cnt[11];
const long long MOD = 1e9 + 7;
int main() {
  string m;
  cin >> m;
  int n = m.size();
  memset(f, 0, sizeof(f));
  f[0][0][0] = 1;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < 2; ++j)
      for (int k = 0; k < n; ++k) {
        if (j == 1) {
          (f[i + 1][1][k + 1] += 2 * f[i][1][k]) %= MOD;
          (f[i + 1][1][k] += 8 * f[i][1][k]) %= MOD;
        } else {
          for (char d = '0'; d < m[i]; ++d) {
            int k2 = k + ((d == '4' || d == '7') ? 1 : 0);
            (f[i + 1][1][k2] += f[i][0][k]) %= MOD;
          }
          int k2 = k + ((m[i] == '4' || m[i] == '7') ? 1 : 0);
          (f[i + 1][0][k2] += f[i][0][k]) %= MOD;
        }
      }
  for (int i = 0; i <= n; ++i) cnt[i] = f[n][0][i] + f[n][1][i];
  --cnt[0];
  long long ans = 0;
  long long tmp[11];
  for (int x = 1; x <= n; ++x) {
    for (int(a) = (int)(0); (a) < (int)(x); ++(a))
      for (int(b) = (int)(0); (b) < (int)(x); ++(b))
        for (int(c) = (int)(0); (c) < (int)(x); ++(c))
          for (int(p) = (int)(0); (p) < (int)(x); ++(p))
            for (int(q) = (int)(0); (q) < (int)(x); ++(q))
              for (int(r) = (int)(0); (r) < (int)(x); ++(r)) {
                memcpy(tmp, cnt, sizeof(cnt));
                if (a + b + c + p + q + r >= x) continue;
                long long now = 1;
                (now *= tmp[a]) %= MOD;
                tmp[a] = max(0LL, tmp[a] - 1);
                (now *= tmp[b]) %= MOD;
                tmp[b] = max(0LL, tmp[b] - 1);
                (now *= tmp[c]) %= MOD;
                tmp[c] = max(0LL, tmp[c] - 1);
                (now *= tmp[p]) %= MOD;
                tmp[p] = max(0LL, tmp[p] - 1);
                (now *= tmp[q]) %= MOD;
                tmp[q] = max(0LL, tmp[q] - 1);
                (now *= tmp[r]) %= MOD;
                tmp[r] = max(0LL, tmp[r] - 1);
                (now *= tmp[x]) %= MOD;
                (ans += now) %= MOD;
              }
  }
  cout << ans << endl;
  return 0;
}
