#include <bits/stdc++.h>
long long gav = 0;
int n, dig, k;
int num[15];
int arr[15];
int nem[15];
int hana[15];
long long ans;
void bctr(int x, int le) {
  if (x == le) {
    long long q1 = 1, q2 = 0;
    if (le != dig) {
      for (int i = 0; i < le; i++) {
        if (nem[i] == 0) {
          if (i == 0)
            q1 *= 7;
          else
            q1 *= 8;
        } else
          q1 *= 2, q2++;
      }
    } else {
      int kel[5];
      q1 = 0;
      kel[0] = 0, kel[1] = 0;
      for (int i = 0; i < le; i++) kel[nem[i]]++;
      q2 = kel[1];
      for (int i = 0, j = le - 1; i < le; i++, j--) {
        if (nem[i] == 0) {
          int bas = 0;
          if (i == 0) bas = 1;
          kel[0]--;
          gav = 1;
          for (int jj = bas; jj < arr[j]; jj++) {
            if (jj != 4 && jj != 7) {
              gav = 1;
              for (int tt = 0; tt < kel[0]; tt++) gav *= 8;
              for (int tt = 0; tt < kel[1]; tt++) gav *= 2;
              q1 += gav;
            }
          }
          if (arr[j] == 4 || arr[j] == 7) break;
        } else {
          kel[1]--;
          if (arr[j] < 4) break;
          if (arr[j] > 4) {
            gav = 1;
            for (int tt = 0; tt < kel[0]; tt++) gav *= 8;
            for (int tt = 0; tt < kel[1]; tt++) gav *= 2;
            q1 += gav;
            if (arr[j] < 7) break;
          }
          if (arr[j] > 7) {
            gav = 1;
            for (int tt = 0; tt < kel[0]; tt++) gav *= 8;
            for (int tt = 0; tt < kel[1]; tt++) gav *= 2;
            q1 += gav;
            break;
          }
        }
      }
    }
    num[q2] += q1;
    return;
  }
  for (int i = 0; i < 2; i++) nem[x] = i, bctr(x + 1, le);
}
void tap(int x, int y) {
  if (x == 6) {
    int q5 = 0;
    for (int i = 0; i < 6; i++) q5 += hana[i];
    if (q5 >= y) return;
    int diz[15];
    for (int i = 0; i <= 10; i++) diz[i] = num[i];
    long long es = 1;
    for (int i = 0; i < 6; i++) {
      es *= diz[hana[i]];
      diz[hana[i]]--;
      es %= 1000000007;
    }
    es *= num[y];
    es %= 1000000007;
    ans += es;
    ans %= 1000000007;
    return;
  }
  for (int j = 0; j < y; j++) {
    hana[x] = j;
    tap(x + 1, y);
  }
}
int main() {
  scanf("%d", &n);
  dig = 0, k = n;
  int ba1 = 0;
  while (k > 0) {
    arr[dig] = k % 10;
    k /= 10;
    if (arr[dig] == 4 || arr[dig] == 7) ba1++;
    dig++;
  }
  for (int j = 1; j <= dig; j++) bctr(0, j);
  num[ba1]++;
  for (int j = 1; j <= 10; j++)
    if (num[j] != 0) tap(0, j);
  int kel = ans % 1000000007;
  printf("%d\n", kel);
  getchar();
  getchar();
}
