Problem: There have recently been elections in the zoo. Overall there were 7 main political parties: one of them is the Little Elephant Political Party, 6 other parties have less catchy names.

Political parties find their number in the ballot highly important. Overall there are m possible numbers: 1, 2, ..., m. Each of these 7 parties is going to be assigned in some way to exactly one number, at that, two distinct parties cannot receive the same number.

The Little Elephant Political Party members believe in the lucky digits 4 and 7. They want to evaluate their chances in the elections. For that, they need to find out, how many correct assignments are there, such that the number of lucky digits in the Little Elephant Political Party ballot number is strictly larger than the total number of lucky digits in the ballot numbers of 6 other parties. 

Help the Little Elephant Political Party, calculate this number. As the answer can be rather large, print the remainder from dividing it by 1000000007 (109 + 7).

Input

A single line contains a single positive integer m (7 ≤ m ≤ 109) — the number of possible numbers in the ballot.

Output

In a single line print a single integer — the answer to the problem modulo 1000000007 (109 + 7).

Examples

Input

7


Output

0


Input

8


Output

1440

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
long long int const mod = 1000000007;
long long int countDivisors(long long int n) {
  long long int cnt = 0;
  for (long long int i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      if (n / i == i)
        cnt++;
      else
        cnt = cnt + 2;
    }
  }
  return cnt;
}
long long int power(long long int x, long long int y) {
  long long int temp;
  if (y == 0) return 1;
  temp = power(x, y / 2);
  if (y % 2 == 0)
    return ((temp) * (temp));
  else
    return (((x)) * ((temp * temp)));
}
long long int gcd1(long long int a, long long int b) {
  if (a == 0) return b;
  return gcd1(b % a, a);
}
long long int lcm(long long int a, long long int b) {
  return (a * b) / gcd1(a, b);
}
long long int fac[8];
long long int ncr[7][7];
long long int dp[20][200][100];
void precompute() {
  fac[0] = 1;
  for (int i = 1; i <= 7; i++) {
    fac[i] = fac[i - 1] * i;
  }
  for (int i = 1; i <= 6; i++) {
    for (int j = 0; j < (int)i + 1; j++) {
      ncr[i][j] = fac[i] / (fac[j] * fac[i - j]);
    }
  }
}
void solvebreaking(long long int n) {
  long long int temp = n;
  int k = 0;
  while (temp) {
    k++;
    temp /= 10;
  }
  int d;
  for (int i = k; i >= 1; i--) {
    d = ((n - n % (power(10, i - 1))) / power(10, i - 1)) % 10;
    if (i == k) {
      for (int j = 0; j < (int)d; j++) {
        if (j == 4 || j == 7) {
          dp[i][1][0]++;
        } else {
          dp[i][0][0]++;
        }
      }
      if (d == 4 || d == 7) {
        dp[i][1][1]++;
      } else {
        dp[i][0][1]++;
      }
      continue;
    }
    for (int j = 0; j < (int)10; j++) {
      for (int k = 0; k < (int)d; k++) {
        if (k == 4 || k == 7) {
          if (j != 0) {
            dp[i][j][0] += dp[i + 1][j - 1][0] + dp[i + 1][j - 1][1];
          }
        } else {
          dp[i][j][0] += dp[i + 1][j][0] + dp[i + 1][j][1];
        }
      }
      if (d == 4 || d == 7) {
        dp[i][j][1] += dp[i + 1][j - 1][1];
      } else {
        dp[i][j][1] += dp[i + 1][j][1];
      }
      for (int k = d; k <= 9; k++) {
        if (k == 4 || k == 7) {
          if (j != 0) {
            dp[i][j][0] += dp[i + 1][j - 1][0];
          }
        } else {
          dp[i][j][0] += dp[i + 1][j][0];
        }
      }
    }
  }
  dp[1][0][0]--;
}
void doit(long long int &t, long long int &c) {
  if (!c) {
    t = 0;
    return;
  }
  t = t * c % mod;
  --c;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int n;
  cin >> n;
  precompute();
  solvebreaking(n);
  long long int ans = 0;
  long long int temp1;
  long long int cnt1[10], cnt2[10];
  for (int i = 0; i < (int)10; i++) {
    cnt1[i] = dp[1][i][0] + dp[1][i][1];
  }
  for (int i1 = 0; i1 < (int)10; i1++) {
    for (int i2 = 0; i2 < (int)i1; i2++) {
      for (int i3 = 0; i3 < (int)i1 - i2; i3++) {
        for (int i4 = 0; i4 < (int)i1 - i2 - i3; i4++) {
          for (int i5 = 0; i5 < (int)i1 - i2 - i3 - i4; i5++) {
            for (int i6 = 0; i6 < (int)i1 - i2 - i3 - i4 - i5; i6++) {
              for (int i7 = 0; i7 < (int)i1 - i2 - i3 - i4 - i5 - i6; i7++) {
                for (int i = 0; i < (int)10; i++) {
                  cnt2[i] = cnt1[i];
                }
                long long int t = 1;
                doit(t, cnt2[i1]);
                doit(t, cnt2[i2]);
                doit(t, cnt2[i3]);
                doit(t, cnt2[i4]);
                doit(t, cnt2[i5]);
                doit(t, cnt2[i6]);
                doit(t, cnt2[i7]);
                if (t > 0) {
                  ans = (ans + t) % mod;
                }
              }
            }
          }
        }
      }
    }
  }
  cout << ans % mod;
}