#include <bits/stdc++.h>
using namespace std;
const long long B = 1e9 + 7;
int m;
int cnt[10];
int k;
int dig[10];
long long dp[10][10];
int vis[10][10];
int get(int i, int j) {
  if (j < 0 || i < 0) return 0;
  if (j == 0 && i == 0) return dp[i][j] = 1;
  if (vis[i][j]) return dp[i][j];
  vis[i][j] = 1;
  return dp[i][j] = (4LL * get(i, j - 1) + 1LL * get(i - 1, j - 1) +
                     2LL * get(i, j - 1) + 1LL * get(i - 1, j - 1) +
                     2LL * get(i, j - 1)) %
                    B;
}
long long solve(int p) {
  int n = p + 5;
  long long res = 0;
  for (int i1 = 1; i1 <= n; ++i1) {
    for (int i2 = i1 + 1; i2 <= n; ++i2) {
      for (int i3 = i2 + 1; i3 <= n; ++i3) {
        for (int i4 = i3 + 1; i4 <= n; ++i4) {
          for (int i5 = i4 + 1; i5 <= n; ++i5) {
            int cc[10];
            memset(cc, 0, sizeof(cc));
            cc[i1 - 1]++;
            cc[i2 - i1 - 1]++;
            cc[i3 - i2 - 1]++;
            cc[i4 - i3 - 1]++;
            cc[i5 - i4 - 1]++;
            cc[n + 1 - i5 - 1]++;
            long long tmp = 1;
            for (int i = 0; i < 10; ++i) {
              int t = cnt[i];
              while (cc[i] && tmp) {
                tmp = tmp * t % B;
                cc[i]--;
                t--;
              }
            }
            res += tmp;
          }
        }
      }
    }
  }
  return res;
}
int main() {
  scanf("%d", &m);
  int t = m;
  while (t) {
    dig[k++] = t % 10;
    t /= 10;
  }
  for (int i = 0; i <= 9; ++i) {
    t = 0;
    for (int j = k - 1; j >= 0; --j) {
      int ti = i - t;
      if (dig[j] <= 4) {
        cnt[i] += dig[j] * get(ti, j);
      } else if (dig[j] <= 7) {
        cnt[i] +=
            4 * get(ti, j) + 1 * get(ti - 1, j) + (dig[j] - 5) * get(ti, j);
      } else {
        cnt[i] += 4 * get(ti, j) + 1 * get(ti - 1, j) + 2 * get(ti, j) +
                  1 * get(ti - 1, j) + (dig[j] - 8) * get(ti, j);
      }
      if (dig[j] == 4 || dig[j] == 7) {
        t++;
      }
    }
  }
  cnt[0]--;
  cnt[t]++;
  long long ans = 0;
  for (int i = 1; i <= 9; ++i) {
    long long tmp = cnt[i];
    cnt[i]--;
    long long tt = 0;
    for (int j = 0; j < i; ++j) {
      tt += solve(j);
    }
    cnt[i]++;
    tmp = tmp * tt % B;
    ans = (ans + tmp) % B;
  }
  printf("%I64d\n", ans);
  return 0;
}
