#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int n, Tr, c;
int f[12][12][2], a[12];
int T[12], C[12];
void init(int n) {
  c = 1;
  while (n) {
    a[c++] = n % 10;
    n /= 10;
  }
  reverse(a + 1, a + c);
}
int main() {
  while (cin >> n) {
    init(n);
    memset(f, 0, sizeof f);
    f[0][0][1] = 1;
    for (int i = 0; i < c - 1; i++)
      for (int j = 0; j < 12; j++) {
        for (int k = 0; k < 2; k++) {
          if (k) {
            for (int l = 0; l < a[i + 1]; l++) {
              if (l == 4 || l == 7)
                f[i + 1][j + 1][0] += f[i][j][k];
              else
                f[i + 1][j][0] += f[i][j][k];
            }
            if (a[i + 1] == 4 || a[i + 1] == 7)
              f[i + 1][j + 1][1] += f[i][j][k];
            else
              f[i + 1][j][1] += f[i][j][k];
          } else {
            for (int l = 0; l <= 9; l++) {
              if (l == 4 || l == 7)
                f[i + 1][j + 1][0] += f[i][j][k];
              else
                f[i + 1][j][0] += f[i][j][k];
            }
          }
        }
      }
    c--;
    f[c][0][0]--;
    for (int i = 0; i < 12; i++) {
      C[i] = f[c][i][0] + f[c][i][1];
    }
    long long ans = 0;
    for (int i = 1; i < 12; i++) {
      for (int j1 = 0; j1 < i; j1++)
        for (int j2 = 0; j2 < i; j2++)
          for (int j3 = 0; j3 < i; j3++)
            for (int j4 = 0; j4 < i; j4++)
              for (int j5 = 0; j5 < i; j5++)
                for (int j6 = 0; j6 < i; j6++) {
                  if (j1 + j2 + j3 + j4 + j5 + j6 < i) {
                    memset(T, 0, sizeof T);
                    T[j1]++;
                    T[j2]++;
                    T[j3]++;
                    T[j4]++;
                    T[j5]++;
                    T[j6]++;
                    long long tmp = C[i];
                    for (int k = 0; k < i; k++) {
                      int p = 0;
                      for (int l = 0; l < T[k]; l++) {
                        tmp *= C[k] - p;
                        p++;
                        tmp %= mod;
                      }
                    }
                    ans += tmp;
                    ans %= mod;
                  }
                }
    }
    cout << ans << endl;
  }
  return 0;
}
