#include <bits/stdc++.h>
using namespace std;
const long long M = 1000000007;
const int N = 11;
long long f[N][N][2];
long long g[N], ans;
char s[N];
inline void up(long long &a, long long &b) { a += b; }
void init() {
  int i, j, n = strlen(s);
  int m = atoi(s);
  memset(f, 0, sizeof(f));
  f[0][0][1] = 1;
  for (i = 1; i <= n; i++) {
    int v = s[i - 1] - '0';
    for (j = 0; j < 10; j++) {
      for (int k = 0; k < N - 1; k++) {
        up(f[i][k + (j == 4 || j == 7)][0], f[i - 1][k][0]);
        if (j < v) {
          up(f[i][k + (j == 4 || j == 7)][0], f[i - 1][k][1]);
        }
        if (j == v) {
          up(f[i][k + (j == 4 || j == 7)][1], f[i - 1][k][1]);
        }
      }
    }
  }
  int mm = 0;
  for (i = 0; i < N; ++i) {
    mm += f[n][i][0] + f[n][i][1];
    g[i] = f[n][i][0] + f[n][i][1];
  }
  g[0]--;
}
void dfs(int num, int left, long long val, int nn) {
  if (left == 0) {
    if (nn < num) {
      ans = (ans + val) % M;
    }
    return;
  }
  for (int i = 0; i < num; i++) {
    if (nn + i >= num) {
      break;
    } else {
      if (g[i] <= 0) continue;
      g[i]--;
      dfs(num, left - 1, (val * (g[i] + 1)) % M, nn + i);
      g[i]++;
    }
  }
}
int main() {
  int i, j;
  while (cin >> s) {
    init();
    ans = 0;
    for (i = 1; i < N; i++) {
      if (g[i] > 0) {
        dfs(i, 6, g[i], 0);
      }
    }
    cout << ans << endl;
  }
  return 0;
}
