#include <bits/stdc++.h>   using namespace std;   const int MAXN = 21;   const long long MOD = 1000000007;   int n;   long long m;   long long C[MAXN][MAXN];   long long g[MAXN], s[MAXN], ten[MAXN], eight[MAXN];   inline void update(long long& x, long long y) { y %= MOD, x += y, x %= MOD; }   inline long long P(const long long& x, int y) {     if (x < y) return 0;     long long res = 1;     for (long long i = x; i >= x - y + 1; --i) res = (res * i) % MOD;     return res;   }   inline pair<int, int> get(long long num, int x) {     int res4 = 0, res7 = 0;     for (int i = 1; i <= x; ++i) num /= 10;     for (long long i = num; i > 0; i /= 10)       if (i % 10 == 4)         res4++;       else if (i % 10 == 7)         res7++;     return pair<int, int>(res4, res7);   }   inline long long F(const long long& num, int x, int a, int b) {     pair<int, int> p = get(num, x);     a -= p.first, b -= p.second;     if (a < 0 || b < 0 || a + b > x) return 0;     return (((C[x][a] * C[x - a][b]) % MOD) * eight[x - a - b]) % MOD;   }   inline long long G(long long num, int x, int a, int b) {     long long res = 0;     for (; num + ten[x] <= m; num += ten[x]) update(res, F(num, x, a, b));     if (x > 0) {       if (num <= m) update(res, G(num, x - 1, a, b));     } else       update(res, F(num, x, a, b));     return res;   }   inline void preProcess() {     ten[0] = eight[0] = 1;     for (int i = 1; i < MAXN; ++i)       ten[i] = ten[i - 1] * 10, eight[i] = eight[i - 1] * 8;     while (ten[n] <= m) n++;     C[0][0] = 1;     for (int i = 1; i < MAXN; ++i) {       C[i][0] = C[i][i] = 1;       for (int j = 1; j < i; ++j) C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % MOD;     }     for (int i = 0; i <= n; ++i)       for (int j = 0; j <= i; ++j) update(g[i], G(0, n - 1, j, i - j));     g[0]--;   }   inline long long dp(int s, int x, int y, int z) {     if (y < 0 || z < 0) return 0;     if (x == s) return (y == 0) ? 1 : 0;     long long res = 0;     for (int i = 0; i <= y; ++i) {       long long k = (C[y][i] * P(g[x], i)) % MOD;       update(res, k * dp(s, x + 1, y - i, z - i * x));     }     return res;   }   int main() {     scanf( %I64d n , &m);     preProcess();     long long res = 0;     for (int s = 1; s <= n; ++s) update(res, g[s] * dp(s, 0, 6, s - 1));     printf( %I64d n , res);     fclose(stdin);     fclose(stdout);     return 0;   }   