Problem: There have recently been elections in the zoo. Overall there were 7 main political parties: one of them is the Little Elephant Political Party, 6 other parties have less catchy names.

Political parties find their number in the ballot highly important. Overall there are m possible numbers: 1, 2, ..., m. Each of these 7 parties is going to be assigned in some way to exactly one number, at that, two distinct parties cannot receive the same number.

The Little Elephant Political Party members believe in the lucky digits 4 and 7. They want to evaluate their chances in the elections. For that, they need to find out, how many correct assignments are there, such that the number of lucky digits in the Little Elephant Political Party ballot number is strictly larger than the total number of lucky digits in the ballot numbers of 6 other parties. 

Help the Little Elephant Political Party, calculate this number. As the answer can be rather large, print the remainder from dividing it by 1000000007 (109 + 7).

Input

A single line contains a single positive integer m (7 ≤ m ≤ 109) — the number of possible numbers in the ballot.

Output

In a single line print a single integer — the answer to the problem modulo 1000000007 (109 + 7).

Examples

Input

7


Output

0


Input

8


Output

1440

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:128777216")
const long long LINF = 1000000000000000000LL;
const int INF = 1000000000;
const long double eps = 1e-9;
const long double PI = 3.1415926535897932384626433832795l;
using namespace std;
void prepare(string s) {
  if (s.length() != 0) {
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
  }
}
int a[][11] = {
    {20000000, 4194303, 7340032, 5505024, 2293760, 573440, 86016, 7168, 256, 0,
     0},
    {40000000, 8388607, 14680064, 11010048, 4587520, 1146880, 172032, 14336,
     512, 0, 0},
    {60000000, 10485759, 20447232, 17432576, 8486912, 2580480, 501760, 60928,
     4224, 128, 0},
    {80000000, 12582911, 26214400, 23855104, 12386304, 4014080, 831488, 107520,
     7936, 256, 0},
    {100000000, 16777215, 33554432, 29360128, 14680064, 4587520, 917504, 114688,
     8192, 256, 0},
    {120000000, 20971519, 40894464, 34865152, 16973824, 5160960, 1003520,
     121856, 8448, 256, 0},
    {140000000, 25165823, 48234496, 40370176, 19267584, 5734400, 1089536,
     129024, 8704, 256, 0},
    {160000000, 27262975, 54001664, 46792704, 23166976, 7168000, 1419264,
     175616, 12416, 384, 0},
    {180000000, 29360127, 59768832, 53215232, 27066368, 8601600, 1748992,
     222208, 16128, 512, 0},
    {200000000, 33554431, 67108864, 58720256, 29360128, 9175040, 1835008,
     229376, 16384, 512, 0},
    {220000000, 37748735, 74448896, 64225280, 31653888, 9748480, 1921024,
     236544, 16640, 512, 0},
    {240000000, 41943039, 81788928, 69730304, 33947648, 10321920, 2007040,
     243712, 16896, 512, 0},
    {260000000, 44040191, 87556096, 76152832, 37847040, 11755520, 2336768,
     290304, 20608, 640, 0},
    {280000000, 46137343, 93323264, 82575360, 41746432, 13189120, 2666496,
     336896, 24320, 768, 0},
    {300000000, 50331647, 100663296, 88080384, 44040192, 13762560, 2752512,
     344064, 24576, 768, 0},
    {320000000, 54525951, 108003328, 93585408, 46333952, 14336000, 2838528,
     351232, 24832, 768, 0},
    {340000000, 58720255, 115343360, 99090432, 48627712, 14909440, 2924544,
     358400, 25088, 768, 0},
    {360000000, 60817407, 121110528, 105512960, 52527104, 16343040, 3254272,
     404992, 28800, 896, 0},
    {380000000, 62914559, 126877696, 111935488, 56426496, 17776640, 3584000,
     451584, 32512, 1024, 0},
    {400000000, 67108863, 134217728, 117440512, 58720256, 18350080, 3670016,
     458752, 32768, 1024, 0},
    {420000000, 67108863, 138412032, 124780544, 64225280, 20643840, 4243456,
     544768, 39936, 1280, 0},
    {440000000, 67108863, 142606336, 132120576, 69730304, 22937600, 4816896,
     630784, 47104, 1536, 0},
    {460000000, 67108863, 144703488, 137887744, 76152832, 26836992, 6250496,
     960512, 93696, 5248, 128},
    {480000000, 67108863, 146800640, 143654912, 82575360, 30736384, 7684096,
     1290240, 140288, 8960, 256},
    {500000000, 67108863, 150994944, 150994944, 88080384, 33030144, 8257536,
     1376256, 147456, 9216, 256},
    {520000000, 71303167, 158334976, 156499968, 90374144, 33603584, 8343552,
     1383424, 147712, 9216, 256},
    {540000000, 75497471, 165675008, 162004992, 92667904, 34177024, 8429568,
     1390592, 147968, 9216, 256},
    {560000000, 77594623, 171442176, 168427520, 96567296, 35610624, 8759296,
     1437184, 151680, 9344, 256},
    {580000000, 79691775, 177209344, 174850048, 100466688, 37044224, 9089024,
     1483776, 155392, 9472, 256},
    {600000000, 83886079, 184549376, 180355072, 102760448, 37617664, 9175040,
     1490944, 155648, 9472, 256},
    {620000000, 88080383, 191889408, 185860096, 105054208, 38191104, 9261056,
     1498112, 155904, 9472, 256},
    {640000000, 92274687, 199229440, 191365120, 107347968, 38764544, 9347072,
     1505280, 156160, 9472, 256},
    {660000000, 94371839, 204996608, 197787648, 111247360, 40198144, 9676800,
     1551872, 159872, 9600, 256},
    {680000000, 96468991, 210763776, 204210176, 115146752, 41631744, 10006528,
     1598464, 163584, 9728, 256},
    {700000000, 100663295, 218103808, 209715200, 117440512, 42205184, 10092544,
     1605632, 163840, 9728, 256},
    {720000000, 100663295, 222298112, 217055232, 122945536, 44498944, 10665984,
     1691648, 171008, 9984, 256},
    {740000000, 100663295, 226492416, 224395264, 128450560, 46792704, 11239424,
     1777664, 178176, 10240, 256},
    {760000000, 100663295, 228589568, 230162432, 134873088, 50692096, 12673024,
     2107392, 224768, 13952, 384},
    {780000000, 100663295, 230686720, 235929600, 141295616, 54591488, 14106624,
     2437120, 271360, 17664, 512},
    {800000000, 100663295, 234881024, 243269632, 146800640, 56885248, 14680064,
     2523136, 278528, 17920, 512},
    {820000000, 104857599, 242221056, 248774656, 149094400, 57458688, 14766080,
     2530304, 278784, 17920, 512},
    {840000000, 109051903, 249561088, 254279680, 151388160, 58032128, 14852096,
     2537472, 279040, 17920, 512},
    {860000000, 111149055, 255328256, 260702208, 155287552, 59465728, 15181824,
     2584064, 282752, 18048, 512},
    {880000000, 113246207, 261095424, 267124736, 159186944, 60899328, 15511552,
     2630656, 286464, 18176, 512},
    {900000000, 117440511, 268435456, 272629760, 161480704, 61472768, 15597568,
     2637824, 286720, 18176, 512},
    {920000000, 121634815, 275775488, 278134784, 163774464, 62046208, 15683584,
     2644992, 286976, 18176, 512},
    {940000000, 125829119, 283115520, 283639808, 166068224, 62619648, 15769600,
     2652160, 287232, 18176, 512},
    {960000000, 127926271, 288882688, 290062336, 169967616, 64053248, 16099328,
     2698752, 290944, 18304, 512},
    {980000000, 130023423, 294649856, 296484864, 173867008, 65486848, 16429056,
     2745344, 294656, 18432, 512},
    {1000000000, 134217727, 301989888, 301989888, 176160768, 66060288, 16515072,
     2752512, 294912, 18432, 512},
    {2000000000, 134217727, 301989888, 301989888, 176160768, 66060288, 16515072,
     2752512, 294912, 18432, 512},
};
int n;
int b[20];
void readdata() {
  scanf("%d", &n);
  memset(b, 0, sizeof(b));
  int k = 0;
  if (n < 20000000) {
    for (int i = (int)1; i <= (int)n; i++) {
      int d = i;
      int cnt = 0;
      while (d > 0) {
        int k = d % 10;
        if (k == 4 || k == 7) cnt++;
        d /= 10;
      }
      b[cnt]++;
    }
  } else {
    int j = 0;
    for (int i = 0; i < (int)51; i++) {
      if (a[i][0] > n) {
        j = i;
        break;
      }
    }
    j--;
    for (int i = 0; i < (int)10; i++) b[i] = a[j][i + 1];
    for (int i = (int)a[j][0]; i <= (int)n; i++) {
      int d = i;
      int cnt = 0;
      while (d > 0) {
        int k = d % 10;
        if (k == 4 || k == 7) cnt++;
        d /= 10;
      }
      b[cnt]++;
    }
  }
}
void writedata() {}
int mod = 1000000007;
int getct(int k, int n) {
  if (k > n) return 1;
  long long ans = 1;
  for (int i = 0; i < (int)k; i++) {
    ans = ans * n;
    ans %= mod;
    n--;
  }
  return (int)ans;
}
inline bool nextm(int *t, int k) {
  t[0]++;
  for (int i = 0; i < (int)6; i++) {
    if (t[i] == k) {
      t[i] = 0;
      if (i == 5) return false;
      t[i + 1]++;
    }
  }
  return true;
}
void solve() {
  int ans = 0;
  for (int i = (int)1; i <= (int)9; i++) {
    int t[6];
    for (int j = 0; j < (int)6; j++) t[j] = 0;
    do {
      int sum = 0;
      for (int j = 0; j < (int)6; j++) sum += t[j];
      if (sum < i) {
        int c[10];
        memset(c, 0, sizeof(c));
        for (int j = 0; j < (int)6; j++) c[t[j]]++;
        long long locans = 1;
        bool flag = true;
        for (int j = 0; j < (int)10; j++) {
          if (c[j] > 0) {
            if (c[j] > b[j]) {
              flag = false;
              break;
            } else {
              locans = locans * (getct(c[j], b[j]));
              locans %= mod;
            }
          }
        }
        if (flag) {
          locans = locans * b[i];
          locans %= mod;
          ans = ans + locans;
          while (ans >= mod) ans -= mod;
        }
      }
    } while (nextm(t, i));
  }
  printf("%d\n", ans);
}
int main() {
  prepare("");
  readdata();
  solve();
  writedata();
  return 0;
}