#include <bits/stdc++.h>
using namespace std;
const long long M = 1e9 + 7;
long long cnt[12], ans;
void add(long long dgt, long long nlucky, long long num) {
  if (dgt == 0) {
    cnt[nlucky] += num;
    return;
  }
  add(dgt - 1, nlucky, 8 * num);
  add(dgt - 1, nlucky + 1, 2 * num);
}
void DFS(long long g, long long lg, long long le, long long ways) {
  if (g == 6) {
    ans = (ans + ways) % M;
    return;
  }
  for (long long i = 0; i < 10; ++i) {
    if (i + lg < le && cnt[i] > 0) {
      cnt[i]--;
      DFS(g + 1, lg + i, le, (ways * (cnt[i] + 1)) % M);
      cnt[i]++;
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string str;
  cin >> str;
  long long prev = 0;
  for (long long i = 0; i < str.size(); ++i) {
    for (long long j = 0; j < str[i] - '0'; ++j)
      add(str.size() - i - 1, prev + (j == 4 || j == 7), 1);
    prev += (str[i] == '4' || str[i] == '7');
  }
  cnt[prev]++, cnt[0]--;
  for (long long i = 1; i < 10; ++i)
    if (cnt[i] > 0) DFS(0, 0, i, cnt[i]);
  cout << ans << '\n';
  return 0;
}
