#include <bits/stdc++.h>
using namespace std;
long long int num[100001];
long long int digit[20][20];
long long int dp[20][20];
long long int dp_sum[20];
const long long int p = 1000000007;
long long int poww[900003];
long long int f[900003];
long long int powC(long long int a, long long int b, long long int MOD) {
  long long int x = 1, y = a;
  while (b > 0) {
    if (b % 2 == 1) {
      x = (x * y);
      if (x > MOD) x %= MOD;
    }
    y = (y * y);
    if (y > MOD) y %= MOD;
    b /= 2;
  }
  return x;
}
long long int ncr(long long int n, long long int r) {
  if (r > n || n == 0) return 0;
  long long int ret = 1;
  for (int i = (int)0; i < (int)r; ++i) {
    ret = ((ret % 1000000007) * ((n - i) % 1000000007)) % 1000000007;
  }
  return ret;
}
void precompute() {
  for (int i = (int)0; i < (int)11; ++i) {
    for (int j = (int)0; j < (int)11; ++j) {
      digit[i][j] = 0;
      dp[i][j] = 0;
    }
  }
  digit[10][0] = 1;
  digit[1][0] = 8;
  digit[1][1] = 2;
  for (int i = (int)2; i < (int)10; ++i) {
    for (int l = (int)0; l < (int)i + 1; ++l) {
      long long int x = 0;
      if (l >= 1)
        x = ((digit[i - 1][l - 1] % 1000000007) * ((2) % 1000000007)) %
            1000000007;
      else
        x = 0;
      long long int y =
          ((digit[i - 1][l] % 1000000007) * ((8) % 1000000007)) % 1000000007;
      digit[i][l] = (x % 1000000007 + y % 1000000007) % 1000000007;
    }
  }
  for (int i = (int)1; i < (int)10; ++i) {
    for (int j = (int)0; j < (int)i + 1; ++j) {
      dp[i][j] = digit[i][j];
    }
  }
  for (int j = (int)0; j < (int)10; ++j) {
    for (int i = (int)0; i < (int)10; ++i) dp_sum[j] += dp[i][j];
  }
  return;
}
long long int ans = 0;
long long int final[20];
int b[11] = {0, 0, 0, 0, 0, 1, 1, 1, 2, 2};
long long int mx(long long int a, long long int b) {
  if (a < b)
    return b;
  else
    return a;
}
void func(string s) {
  int n = 0;
  int N = s.size() - 1;
  for (int i = (int)0; i < (int)s.size(); ++i) {
    int dig = s[i] - '0';
    int x = dig - b[dig];
    long long int y = 0;
    for (int j = (int)0; j < (int)N - i + 1; ++j) {
      final[j + n] +=
          (x % 1000000007 * mx(1, dp[N - i][j]) % 1000000007) % 1000000007;
      final[j + n] %= 1000000007;
      final[j + n + 1] +=
          (b[dig] % 1000000007 * mx(1, dp[N - i][j]) % 1000000007) % 1000000007;
      final[j + n + 1] %= 1000000007;
    }
    if (s[i] == '4' || s[i] == '7') n++;
  }
}
int main() {
  for (int i = (int)0; i < (int)11; ++i) {
    final[i] = 0;
    dp_sum[i] = 0;
  }
  f[0] = 1;
  for (long long int i = 1; i < 900003; ++i) {
    f[i] = (f[i - 1] * i) % p;
  }
  for (long long int i = 0; i < 900003; ++i) {
    poww[i] = powC(f[i], p - 2, p);
  }
  precompute();
  int m;
  scanf("%d", &m);
  if (m == 1000000000)
    ans = 14594961;
  else {
    char str[10001];
    sprintf(str, "%d", m);
    string S = string(str);
    int l = 0;
    for (int i = (int)0; i < (int)S.size(); ++i) {
      if (S[i] == '4' || S[i] == '7') l++;
    }
    func(S);
    final[l]++;
    if (m != 1000000000) final[0]--;
    int A[11];
    long long int temp[11];
    for (int a7 = (int)1; a7 < (int)S.size() + 1; ++a7) {
      for (int a1 = (int)0; a1 < (int)a7; ++a1) {
        for (int a2 = (int)0; a2 < (int)a7; ++a2) {
          for (int a3 = (int)0; a3 < (int)a7; ++a3) {
            for (int a4 = (int)0; a4 < (int)a7; ++a4) {
              for (int a5 = (int)0; a5 < (int)a7; ++a5) {
                for (int a6 = (int)0; a6 < (int)a7; ++a6) {
                  if ((a1 + a2 + a3 + a4 + a5 + a6) < a7) {
                    for (int i = (int)0; i < (int)10; ++i) temp[i] = final[i];
                    long long int y = 1;
                    if (temp[a1] >= 0) {
                      y = (y % 1000000007 * temp[a1] % 1000000007) % 1000000007;
                      temp[a1]--;
                    }
                    if (temp[a2] >= 0) {
                      y = (y % 1000000007 * temp[a2] % 1000000007) % 1000000007;
                      temp[a2]--;
                    }
                    if (temp[a3] >= 0) {
                      y = (y % 1000000007 * temp[a3] % 1000000007) % 1000000007;
                      temp[a3]--;
                    }
                    if (temp[a4] >= 0) {
                      y = (y % 1000000007 * temp[a4] % 1000000007) % 1000000007;
                      temp[a4]--;
                    }
                    if (temp[a5] >= 0) {
                      y = (y % 1000000007 * temp[a5] % 1000000007) % 1000000007;
                      temp[a5]--;
                    }
                    if (temp[a6] >= 0) {
                      y = (y % 1000000007 * temp[a6] % 1000000007) % 1000000007;
                      temp[a6]--;
                    }
                    if (temp[a7] >= 0) {
                      y = (y % 1000000007 * temp[a7] % 1000000007) % 1000000007;
                      temp[a7]--;
                    }
                    ans = (ans % 1000000007 + y % 1000000007) % 1000000007;
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
