#include <bits/stdc++.h>
using namespace std;
string s;
int n;
int len;
long long dp[10];
int memo[20][20][5];
long long mod = 1e9 + 7;
int solve(int i, int rem, int ok) {
  if (i == len) {
    return rem == 0;
  }
  int &ret = memo[i][rem][ok];
  if (ret != -1) return ret;
  ret = 0;
  for (int j = 0; j < 10; j++) {
    int c = 0;
    if (j == 4 || j == 7) c = 1;
    if (ok) {
      if (rem - c >= 0) ret += solve(i + 1, rem - c, ok);
    } else {
      if (rem - c >= 0 && j <= (s[i] - '0')) {
        if (j < (s[i] - '0'))
          ret += solve(i + 1, rem - c, 1);
        else
          ret += solve(i + 1, rem - c, 0);
      }
    }
  }
  return ret;
}
int main() {
  memset(memo, -1, sizeof(memo));
  cin >> n;
  int x = n;
  while (x > 0) {
    s += char('0' + x % 10);
    x = x /= 10;
  }
  reverse(s.begin(), s.end());
  len = s.length();
  for (int i = 0; i < 10; i++) {
    dp[i] = solve(0, i, 0);
  }
  dp[0]--;
  long long res = 0;
  for (int p1 = 0; p1 < 10; p1++) {
    long long cnt[7] = {0};
    cnt[0] = dp[p1];
    if (dp[p1] == 0) continue;
    dp[p1]--;
    for (int p2 = 0; p2 < 10; p2++) {
      if (dp[p2] == 0) continue;
      cnt[1] = dp[p2] * cnt[0];
      cnt[1] %= mod;
      dp[p2]--;
      for (int p3 = 0; p3 < 10; p3++) {
        if (dp[p3] == 0) continue;
        cnt[2] = dp[p3] * cnt[1];
        cnt[2] %= mod;
        dp[p3]--;
        for (int p4 = 0; p4 < 10; p4++) {
          if (dp[p4] == 0) continue;
          cnt[3] = dp[p4] * cnt[2];
          cnt[3] %= mod;
          dp[p4]--;
          for (int p5 = 0; p5 < 10; p5++) {
            if (dp[p5] == 0) continue;
            cnt[4] = dp[p5] * cnt[3];
            cnt[4] %= mod;
            dp[p5]--;
            for (int p6 = 0; p6 < 10; p6++) {
              if (dp[p6] == 0) continue;
              cnt[5] = dp[p6] * cnt[4];
              cnt[5] %= mod;
              dp[p6]--;
              for (int p7 = 0; p7 < 10; p7++) {
                if (dp[p7] == 0) continue;
                cnt[6] = dp[p7] * cnt[5];
                cnt[6] %= mod;
                if (p1 > p2 + p3 + p4 + p5 + p6 + p7) res += cnt[6];
                res %= mod;
              }
              dp[p6]++;
            }
            dp[p5]++;
          }
          dp[p4]++;
        }
        dp[p3]++;
      }
      dp[p2]++;
    }
    dp[p1]++;
  }
  cout << res << endl;
}
