#include <bits/stdc++.h>
using namespace std;
long long dp[20][20];
long long nu[10], f[20];
long long p;
long long ans;
long long dfs(int len, int num, bool limit) {
  if (num > p) return 0;
  if (len == -1) return 1;
  if (!limit && dp[len][p - num] != -1) return dp[len][p - num];
  int up = limit ? f[len] : 9;
  long long sum = 0;
  for (int i = 0; i <= up; i++) {
    sum = (sum + dfs(len - 1, num + (i == 4 || i == 7), limit && i == up)) %
          1000000007;
  }
  if (!limit) dp[len][p - num] = sum;
  return sum;
}
long long get(long long a, int i) {
  int len = -1;
  while (a) {
    f[++len] = a % 10;
    a /= 10;
  }
  return dfs(len, 0, 1);
}
void d(int num, long long x, int a) {
  if (a < 0) {
    return;
  }
  if (num == 0) {
    ans = (ans + x) % 1000000007;
    return;
  }
  for (int i = 0; i <= 9; i++) {
    if (nu[i] == 0) continue;
    nu[i]--;
    d(num - 1, (x * (nu[i] + 1) % 1000000007), a - i);
    nu[i]++;
  }
}
int main() {
  long long a;
  cin >> a;
  memset(dp, -1, sizeof(dp));
  for (int i = 9; i >= 0; i--) {
    p = i;
    nu[i] = get(a, i);
  }
  for (int i = 9; i != 0; i--) nu[i] -= nu[i - 1];
  nu[0]--;
  for (int i = 9; i >= 1; i--) {
    if (nu[i] <= 0) continue;
    d(6, nu[i], i - 1);
  }
  cout << (ans + 1000000007) % 1000000007 << endl;
  return 0;
}
