#include <bits/stdc++.h>
long long mpow(long long a, long long n, long long mod) {
  long long ret = 1;
  long long b = a;
  while (n) {
    if (n & 1) ret = (ret * b) % mod;
    b = (b * b) % mod;
    n >>= 1;
  }
  return (long long)ret;
}
using namespace std;
vector<int> v;
long long dp[15][15][6];
long long ans = 0;
long long cnt[11];
void dfs(int pos, int sum, long long x) {
  int i;
  if (pos == 7) {
    if (sum > 0) {
      ans += x;
      if (ans >= 1000000007) ans -= 1000000007;
    }
    return;
  }
  for (i = 0; i < 10; i++)
    if (cnt[i] > 0) {
      long long y = (x * cnt[i]) % 1000000007;
      cnt[i]--;
      if (pos == 0)
        dfs(pos + 1, sum + i, y);
      else
        dfs(pos + 1, sum - i, y);
      cnt[i]++;
    }
}
int main() {
  int m;
  cin >> m;
  int i, j, k;
  m++;
  for (i = 0; i < 10; i++) {
    v.push_back(m % 10);
    m /= 10;
  }
  reverse(v.begin(), v.end());
  dp[0][0][0] = 1;
  for (i = 0; i < 10; i++) {
    for (k = 0; k < 2; k++) {
      for (j = 0; j < 11; j++) {
        if (dp[i][j][k] > 0) {
          if (k == 0) {
            int ok1 = (v[i] == 4 || v[i] == 7) ? 1 : 0;
            dp[i + 1][j + ok1][k] =
                (dp[i + 1][j + ok1][k] + dp[i][j][k]) % 1000000007;
            for (int ok = 0; ok < v[i]; ok++) {
              int ok1 = (ok == 4 || ok == 7) ? 1 : 0;
              dp[i + 1][j + ok1][1] =
                  (dp[i + 1][j + ok1][1] + dp[i][j][k]) % 1000000007;
            }
          } else {
            dp[i + 1][j + 1][k] =
                (dp[i + 1][j + 1][k] + dp[i][j][k] * 2ll) % 1000000007;
            dp[i + 1][j][k] =
                (dp[i + 1][j][k] + dp[i][j][k] * 8ll) % 1000000007;
          }
        }
      }
    }
  }
  for (i = 0; i < 10; i++) {
    cnt[i] = dp[10][i][1];
  }
  cnt[0] = (cnt[0] + 1000000007 - 1) % 1000000007;
  dfs(0, 0, 1);
  cout << ans;
  return 0;
}
