#include <bits/stdc++.h>
using namespace std;
int luckydecompose(long long n, long long x[10]) {
  int i;
  if (n == 0) {
    for (i = 0; i < 10; i++) x[i] = 0;
    return 0;
  } else if (n % 10 == 9) {
    long long y[10];
    luckydecompose(n / 10, y);
    for (i = 0; i < 10; i++) {
      if (i == 0)
        x[0] = y[0] * 8 + 7;
      else if (i == 1)
        x[1] = y[1] * 8 + 2 * y[0] + 2;
      else
        x[i] = y[i] * 8 + 2 * y[i - 1];
    }
    return 0;
  } else {
    luckydecompose(n - 1, x);
    long long nn = n, sum = 0;
    while (nn != 0) {
      if (nn % 10 == 4 || nn % 10 == 7) sum++;
      nn /= 10;
    }
    x[sum]++;
    return 0;
  }
}
long long many(long long* a, int lepp, int b, int c, int d, int e, int f,
               int g) {
  long long prod = 0;
  for (int i = lepp; i < 10; i++) prod += a[i];
  prod *= a[b];
  a[b]--;
  prod %= 1000000007;
  prod *= a[c];
  a[c]--;
  prod %= 1000000007;
  prod *= a[d];
  a[d]--;
  prod %= 1000000007;
  prod *= a[e];
  a[e]--;
  prod %= 1000000007;
  prod *= a[f];
  a[f]--;
  prod %= 1000000007;
  prod *= a[g];
  a[g]--;
  prod %= 1000000007;
  a[b]++;
  a[c]++;
  a[d]++;
  a[e]++;
  a[f]++;
  a[g]++;
  return prod;
}
int main() {
  long long a[10], m;
  cin >> m;
  luckydecompose(m, a);
  long long fullcount = 0;
  int lepp, b, c, d, e, f, g;
  for (b = 0; b < 10; b++)
    for (c = 0; c < 10 - b; c++)
      for (d = 0; d < 10 - b - c; d++)
        for (e = 0; e < 10 - b - c - d; e++)
          for (f = 0; f < 10 - b - c - d - e; f++)
            for (g = 0; g < 10 - b - c - d - e - f; g++) {
              lepp = b + c + d + e + f + g + 1;
              fullcount += many(a, lepp, b, c, d, e, f, g);
              fullcount %= 1000000007;
            }
  cout << fullcount;
}
