#include <bits/stdc++.h>   using namespace std;   const int M = 10 + 10;   int minn0[M][M];   int minn[M][M];   int dig[M];   int dignum;   int fac(int x) {     int ans = 1;     for (int i = 1; i <= x; i++) {       ans = ans * i;     }     return ans;   }   int ex(int a, int x) {     int ans = 1;     for (int i = 1; i <= x; i++) {       ans = ans * a;     }     return ans;   }   void mluckyinn0() {     for (int n = 1; n <= 9; n++) {       for (int m = 0; m <= n; m++) {         minn0[0][m] = 1;         int nchm = fac(n) / fac(m) / fac(n - m);         int lucky = ex(2, m);         int unlucky = ex(8, n - m);         minn0[n][m] = nchm * lucky * unlucky;       }     }   }   void mluckyinn() {     minn[1][0] = 7;     minn[1][1] = 2;     for (int n = 2; n <= 9; n++) {       for (int m = 0; m <= n; m++) {         int t1 = 0;         if (m - 1 >= 0 && n - 1 >= 0) {           t1 = minn0[n - 1][m - 1];         }         minn[n][m] = 2 * t1 + 7 * minn0[n - 1][m];       }     }   }   void caldig(int x) {     int idx = 0;     while (x > 0) {       dig[dignum - idx] = x % 10;       x = x / 10;       idx++;     }   }   int lnum[M];   long long int mod = 1000000000 + 7;   int main() {     int m;     cin >> m;     mluckyinn0();     mluckyinn();     int tmp = m;     while (tmp > 0) {       dignum++;       tmp /= 10;     }     caldig(m);     for (int d = 1; d < dignum; d++) {       for (int j = 0; j <= d; j++) {         lnum[j] = lnum[j] + minn[d][j];       }     }     int pre = 0;     int fi = 0;     for (int i = 1; i <= dignum; i++) {       int st = 0;       if (i == 1) {         st = 1;       }       int y47 = 0;       int n47 = 0;       for (int j = st; j < dig[i]; j++) {         if (j == 4 || j == 7) {           y47++;         } else {           n47++;         }       }       int flag = 0;       if (y47 > 0) {         flag = 1;       }       int ndg = dignum - i;       for (int j = 0; j <= ndg; j++) {         lnum[pre + j] = lnum[pre + j] + minn0[ndg][j] * n47;         lnum[pre + j + flag] = lnum[pre + j + flag] + minn0[ndg][j] * y47;       }       if (dig[i] == 4 || dig[i] == 7) {         pre++;       }     }     lnum[pre]++;     long long int ans = 0;     int sta[M];     for (int i1 = 0; i1 <= 9; i1++) {       sta[1] = lnum[i1];       lnum[i1]--;       for (int i2 = 0; i2 <= 9; i2++) {         sta[2] = lnum[i2];         lnum[i2]--;         for (int i3 = 0; i3 <= 9; i3++) {           sta[3] = lnum[i3];           lnum[i3]--;           for (int i4 = 0; i4 <= 9; i4++) {             sta[4] = lnum[i4];             lnum[i4]--;             for (int i5 = 0; i5 <= 9; i5++) {               sta[5] = lnum[i5];               lnum[i5]--;               for (int i6 = 0; i6 <= 9; i6++) {                 sta[6] = lnum[i6];                 lnum[i6]--;                 int st = i1 + i2 + i3 + i4 + i5 + i6;                 for (int i7 = st + 1; i7 <= 9; i7++) {                   sta[7] = lnum[i7];                   lnum[i7]--;                   long long int val = 1;                   for (int j = 1; j <= 7; j++) {                     if (sta[j] <= 0) {                       val = 0;                       break;                     } else {                       val = (val * sta[j]) % mod;                     }                   }                   ans = (ans + val) % mod;                   lnum[i7]++;                 }                 lnum[i6]++;               }               lnum[i5]++;             }             lnum[i4]++;           }           lnum[i3]++;         }         lnum[i2]++;       }       lnum[i1]++;     }     cout << ans << endl;     return 0;   }