#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e9 + 7;
const double PI = 3.14159265358979323846264338;
vector<long long int> no;
vector<vector<vector<long long int>>> dp(
    12, vector<vector<long long int>>(12, vector<long long int>(2, 0)));
void fun() {
  long long int indd = (long long int)(no.size()) - 1;
  dp[indd][0][1] = 8;
  dp[indd][1][1] = 2;
  for (long long int i = 0; i <= no[indd]; i++) {
    long long int req = 0;
    if (i == 4 || i == 7) {
      req = 1;
    }
    dp[indd][req][0]++;
  }
  for (long long int ind = (long long int)(no.size()) - 2; ind >= 0; ind--) {
    for (long long int req = 0; req <= 9; req++) {
      for (long long int less = 0; less <= 1; less++) {
        long long int higher;
        if (less == 0) {
          higher = no[ind];
        } else {
          higher = 9;
        }
        for (long long int x = 0; x <= higher; x++) {
          long long int new_req = req;
          if (x == 4 || x == 7) {
            new_req--;
          }
          long long int ch = (x < no[ind]);
          long long int new_less = (less | ch);
          if (new_req >= 0) {
            dp[ind][req][less] += dp[ind + 1][new_req][new_less];
            dp[ind][req][less] %= MOD;
          }
        }
      }
    }
  }
}
void solve() {
  long long int m;
  cin >> m;
  long long int tmp = m;
  while (tmp > 0) {
    no.push_back(tmp % 10);
    tmp /= 10;
  }
  reverse(no.begin(), no.end());
  fun();
  map<long long int, long long int> mp;
  long long int tot = 0;
  for (long long int i = 1; i <= 9; i++) {
    mp[i] = dp[0][i][0];
    tot += dp[0][i][0];
  }
  mp[0] = m - tot;
  long long int ans = 0;
  for (long long int i = 1; i <= 9; i++) {
    vector<long long int> tmp;
    tmp.push_back(mp[i]);
    mp[i]--;
    for (long long int a = 0; a <= 9; a++) {
      tmp.push_back(mp[a]);
      mp[a]--;
      for (long long int b = 0; b < i; b++) {
        tmp.push_back(mp[b]);
        mp[b]--;
        for (long long int c = 0; c < i; c++) {
          tmp.push_back(mp[c]);
          mp[c]--;
          for (long long int d = 0; d < i; d++) {
            tmp.push_back(mp[d]);
            mp[d]--;
            for (long long int e = 0; e < i; e++) {
              tmp.push_back(mp[e]);
              mp[e]--;
              for (long long int f = 0; f < i; f++) {
                tmp.push_back(mp[f]);
                mp[f]--;
                long long int calc = a + b + c + d + e + f;
                if (i > calc) {
                  long long int no = 1;
                  for (long long int j = 0; j < (long long int)(tmp.size());
                       j++) {
                    no *= tmp[j];
                    no %= MOD;
                  }
                  ans += no;
                  ans %= MOD;
                }
                tmp.pop_back();
                mp[f]++;
              }
              tmp.pop_back();
              mp[e]++;
            }
            tmp.pop_back();
            mp[d]++;
          }
          tmp.pop_back();
          mp[c]++;
        }
        tmp.pop_back();
        mp[b]++;
      }
      tmp.pop_back();
      mp[a]++;
    }
    tmp.pop_back();
    mp[i]++;
  }
  cout << ans << "\n";
}
int main(void) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
