#include <bits/stdc++.h>
using namespace std;
int target;
int x[11];
int memo[32][10][10][2];
int cont = 0;
void construct(int t) {
  while (t != 0) {
    x[cont++] = t % 10;
    t /= 10;
  }
  reverse(x, x + cont);
  return;
}
int dp(int pos, int cant, int lucky, int menor) {
  if (pos == cont) {
    if (cant == lucky) return 1;
    return 0;
  }
  if (memo[pos][cant][lucky][menor] != -1) return memo[pos][cant][lucky][menor];
  int dev = 0;
  if (menor) {
    for (int i = 0; i < 10; i++) {
      dev += dp(pos + 1, cant + (i == 4 || i == 7), lucky, menor);
    }
  } else {
    for (int i = 0; i < x[pos]; i++) {
      dev += dp(pos + 1, cant + (i == 4 || i == 7), lucky, 1);
    }
    dev += dp(pos + 1, cant + (x[pos] == 4 || x[pos] == 7), lucky, 0);
  }
  memo[pos][cant][lucky][menor] = dev;
  return dev;
}
long long var(long long n, int k) {
  if (k == 1) return n;
  long long dev = 1;
  long long abajo = 1;
  for (int i = 1; i <= k; i++) {
    dev = (dev * (n - i + 1)) % 1000000007LL;
  }
  return dev;
}
int main() {
  int c[10];
  int m;
  while (cin >> m) {
    target = m;
    cont = 0;
    construct(target);
    memset(memo, -1, sizeof(memo));
    for (int i = 0; i < 10; i++) c[i] = dp(0, 0, i, 0);
    c[0]--;
    long long hamletov = 0;
    for (int i = 0; i < cont; i++)
      for (int j = 0; j < cont; j++)
        for (int k = 0; k < cont; k++)
          for (int L = 0; L < cont; L++)
            for (int mm = 0; mm < cont; mm++)
              for (int nn = 0; nn < cont; nn++) {
                int tot = i + j + k + L + mm + nn;
                if (tot >= 9) continue;
                int value[10];
                memset(value, 0, sizeof(value));
                value[i]++;
                value[j]++;
                value[k]++;
                value[L]++;
                value[mm]++;
                value[nn]++;
                long long dev = 1;
                for (int h = 0; h < cont; h++) {
                  if (value[h] == 0) continue;
                  dev = (dev * var(c[h], value[h])) % 1000000007LL;
                }
                for (int h = tot + 1; h < 10; h++) {
                  hamletov = (hamletov + dev * c[h]) % 1000000007LL;
                }
              }
    cout << hamletov << endl;
  }
  return 0;
}
