#include <bits/stdc++.h>
using namespace std;
const long long mod = (long long)1e9 + 7;
int p2[15], p8[15], p10[15], dp[15][15], c[15][15], pd[15];
int m, cs;
long long res;
int countLuck(int x) {
  int res = 0;
  while (x) {
    if (x % 10 == 4 || x % 10 == 7) res++;
    x /= 10;
  }
  return res;
}
int countCs(int x) {
  int res = 0;
  while (x) res++, x /= 10;
  return res;
}
void calculateTohop() {
  c[0][0] = 1;
  for (int i = 1; i <= cs; i++) {
    c[i][0] = c[i][i] = 1;
    for (int j = 1; j < i; j++) c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
  }
}
void init() {
  cs = countCs(m);
  calculateTohop();
  p2[0] = p8[0] = 1;
  for (int i = 1; i <= cs; i++) {
    p2[i] = p2[i - 1] * 2, p8[i] = p8[i - 1] * 8;
    if (i < cs) dp[i][i] += p2[i];
    if (i < cs) dp[i][0] += p8[i - 1] * 7;
  }
  dp[0][0] = 1;
  for (int len = 1; len < cs; len++)
    for (int x = 1; x < len; x++) {
      int y = len - x;
      int res1 = c[len - 1][x - 1] * p8[x - 1] * 7 * p2[y];
      int res2 = c[len - 1][y - 1] * p2[y] * p8[x];
      dp[len][y] += res1 + res2;
    }
}
void calLast() {
  int start, cntLuck = 0, tmp;
  p10[0] = 1;
  for (int i = 1; i < cs; i++) p10[i] = p10[i - 1] * 10;
  for (int i = 1; i <= cs; i++) {
    int x = (m / p10[cs - i]) % 10;
    if (i == 1)
      start = 1;
    else
      start = 0;
    for (int j = start; j < x; j++) {
      if (j == 4 || j == 7)
        tmp = 1;
      else
        tmp = 0;
      for (int k = 0; k <= cs - cntLuck - tmp; k++) {
        for (int l = 0; l <= cs - i; l++)
          dp[cs][cntLuck + tmp + k] += dp[cs - i - l][k];
      }
    }
    if (x == 4 || x == 7) cntLuck++;
  }
  dp[cs][countLuck(m)]++;
}
long long mult(long long a, long long b) { return (a * b) % mod; }
void solve() {
  for (int i = 1; i <= cs; i++)
    for (int j = 0; j <= cs; j++) pd[j] += dp[i][j];
  int bb[15];
  long long tmp;
  for (int x1 = 1; x1 <= cs; x1++) {
    for (int x2 = 0; x2 <= x1 - 1; x2++)
      for (int x3 = 0; x3 <= x1 - 1 - x2; x3++)
        for (int x4 = 0; x4 <= x1 - 1 - x2 - x3; x4++)
          for (int x5 = 0; x5 <= x1 - 1 - x2 - x3 - x4; x5++)
            for (int x6 = 0; x6 <= x1 - 1 - x2 - x3 - x4 - x5; x6++)
              for (int x7 = 0; x7 <= x1 - 1 - x2 - x3 - x4 - x5 - x6; x7++) {
                memset(bb, 0, sizeof bb);
                tmp = mult(pd[x1], pd[x2]);
                bb[x2]++;
                tmp = mult(tmp, (pd[x3] - bb[x3]));
                bb[x3]++;
                tmp = mult(tmp, (pd[x4] - bb[x4]));
                bb[x4]++;
                tmp = mult(tmp, (pd[x5] - bb[x5]));
                bb[x5]++;
                tmp = mult(tmp, (pd[x6] - bb[x6]));
                bb[x6]++;
                tmp = mult(tmp, (pd[x7] - bb[x7]));
                res = (res + tmp) % mod;
              }
  }
  cout << res << endl;
}
int main() {
  if (0) {
    freopen("a.inp", "r", stdin);
    freopen("a.out", "w", stdout);
  };
  scanf("%d", &m);
  init();
  calLast();
  solve();
}
