#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
long long int fac[20];
long long int modularExponentiation(long long int x, long long int n,
                                    long long int M) {
  long long int result = 1;
  while (n > 0) {
    if (n % 2 == 1)
      result = ((result % 1000000007ll) * (x % 1000000007ll)) % 1000000007ll;
    x = ((x % 1000000007ll) * (x % 1000000007ll)) % 1000000007ll;
    n = n / 2;
  }
  return result;
}
long long int binaryExponentiation(long long int x, long long int n) {
  long long int result = 1;
  while (n > 0) {
    if (n % 2 == 1) result = result * x;
    x = x * x;
    n = n / 2;
  }
  return result;
}
long long int pow1(long long int x, long long int y) {
  long long int z = 1;
  while (y--) {
    z = z * x;
  }
  return z;
}
long long int modInverse(long long int n, long long int p) {
  return modularExponentiation(n, p - 2, p);
}
unsigned long long nCrModPFermat(unsigned long long n, long long int r,
                                 long long int p) {
  if (r == 0) return 1;
  return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) %
         p;
}
long long int check(long long int x, long long int y) {
  long long int z = 1;
  long long int ans = 0;
  while (z < x) {
    ans++;
    z *= y;
  }
  return ans;
}
long long int countbits(long long int n) {
  long long int x = 0;
  while (n > 0) {
    x++;
    n = (n & (n - 1));
  }
  return x;
}
long long int smallncr(long long int n, long long int r) {
  if (r > n)
    return 0;
  else {
    long long int pro = 1;
    for (long long int i = n - r + 1; i <= n; i++)
      pro = (pro * i) % 1000000007ll;
    return pro;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  fac[0] = 1;
  for (long long int i = 1; i <= 10; i++)
    fac[i] = (i * fac[i - 1]) % 1000000007ll;
  long long int m;
  cin >> m;
  vector<long long int> dig;
  long long int x = m;
  while (x) {
    dig.push_back(x % 10);
    x /= 10;
  }
  reverse((dig).begin(), (dig).end());
  long long int n = dig.size();
  long long int dp[n][n + 1];
  for (long long int i = n - 1; i >= 0; i--) {
    if (i == (n - 1)) {
      dp[i][0] = 8;
      dp[i][1] = 2;
      for (long long int j = 2; j <= n; j++) dp[i][j] = 0;
    } else {
      long long int z = n - i;
      dp[i][0] = (8 * dp[i + 1][0]) % 1000000007ll;
      for (long long int j = 1; j <= z; j++) {
        dp[i][j] = ((((8 % 1000000007ll) * (dp[i + 1][j] % 1000000007ll)) %
                     1000000007ll % 1000000007ll) +
                    (((2 % 1000000007ll) * (dp[i + 1][j - 1] % 1000000007ll)) %
                     1000000007ll % 1000000007ll)) %
                   1000000007ll;
      }
      for (long long int j = (z + 1); j <= n; j++) {
        dp[i][j] = 0;
      }
    }
  }
  vector<long long int> count(n + 1, 0);
  long long int c = 0;
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < dig[i]; j++) {
      if (j == 4 || j == 7) {
        if ((i + 1) < n) {
          for (long long int x = c + 1; x <= n; x++) {
            count[x] += dp[i + 1][x - (c + 1)];
            count[x] %= 1000000007ll;
          }
        } else {
          count[c + 1]++;
          count[c + 1] %= 1000000007ll;
        }
      } else {
        if ((i + 1) < n) {
          for (long long int x = c; x <= n; x++) {
            count[x] += dp[i + 1][x - c];
            count[x] %= 1000000007ll;
          }
        } else {
          count[c]++;
          count[c] %= 1000000007ll;
        }
      }
    }
    if (dig[i] == 4 || dig[i] == 7) c++;
  }
  count[c]++;
  count[0]--;
  long long int ans = 0;
  for (long long int x1 = 0; x1 < n; x1++) {
    for (long long int x2 = 0; (x2 + x1) < n; x2++) {
      for (long long int x3 = 0; (x1 + x2 + x3) < n; x3++) {
        for (long long int x4 = 0; (x1 + x2 + x3 + x4) < n; x4++) {
          for (long long int x5 = 0; (x1 + x2 + x3 + x4 + x5) < n; x5++) {
            for (long long int x6 = 0; (x1 + x2 + x3 + x4 + x5 + x6) < n;
                 x6++) {
              long long int s = (x1 + x2 + x3 + x4 + x5 + x6);
              vector<long long int> freq(n + 1, 0);
              long long int val2 = 1;
              freq[x1]++;
              freq[x2]++;
              freq[x3]++;
              freq[x4]++;
              freq[x5]++;
              freq[x6]++;
              for (long long int i = 0; i <= n; i++) {
                if (count[i] >= freq[i])
                  freq[i] = count[i];
                else {
                  val2 = 0;
                  break;
                }
              }
              for (long long int i = 0; i <= n; i++) freq[i] = count[i];
              long long int val1 = 0;
              for (long long int k = s + 1; k <= n; k++) {
                val1 += count[k];
                val1 %= 1000000007ll;
              }
              if (val2 == 1) {
                val2 *= freq[x1];
                val2 %= 1000000007ll;
                freq[x1] = ((freq[x1] % 1000000007ll) - (1 % 1000000007ll) +
                            1000000007ll) %
                           1000000007ll;
                val2 *= freq[x2];
                val2 %= 1000000007ll;
                freq[x2] = ((freq[x2] % 1000000007ll) - (1 % 1000000007ll) +
                            1000000007ll) %
                           1000000007ll;
                val2 *= freq[x3];
                val2 %= 1000000007ll;
                freq[x3] = ((freq[x3] % 1000000007ll) - (1 % 1000000007ll) +
                            1000000007ll) %
                           1000000007ll;
                val2 *= freq[x4];
                val2 %= 1000000007ll;
                freq[x4] = ((freq[x4] % 1000000007ll) - (1 % 1000000007ll) +
                            1000000007ll) %
                           1000000007ll;
                val2 *= freq[x5];
                val2 %= 1000000007ll;
                freq[x5] = ((freq[x5] % 1000000007ll) - (1 % 1000000007ll) +
                            1000000007ll) %
                           1000000007ll;
                val2 *= freq[x6];
                val2 %= 1000000007ll;
                freq[x6] = ((freq[x6] % 1000000007ll) - (1 % 1000000007ll) +
                            1000000007ll) %
                           1000000007ll;
              }
              ans += ((val1 % 1000000007ll) * (val2 % 1000000007ll)) %
                     1000000007ll;
              ans %= 1000000007ll;
            }
          }
        }
      }
    }
  }
  cout << ans;
}
