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 PYTHON):

Solution:
cnt_party = [0 for i in range(12)]

def C(n, k):
    global mod
    if k > n: return 0
    ret = 1
    for i in range(n - k + 1, n + 1):
        ret = (ret * i) % mod
    return ret 

def go(s, pos):
    global cnt, cnt_party, mod
    if s < 1: return 0
    if pos == 6:
        ret = 1
        for i in range(12):
            ret = (ret * C(cnt[i], cnt_party[i])) % mod
        return ret
    ret = 0
    for i in range(s):
        cnt_party[i] += 1
        ret += go(s - i, pos + 1)
        cnt_party[i] -= 1
        if ret >= mod: ret -= mod
    return ret


n = raw_input()
mod = 10 ** 9 + 7
d = [[[0 for i in range(2)] for j in range(12)] for k in range(12)]
d[0][0][0] = 1
for i in range(1, len(n) + 1): # length
    for j in range(i + 1): # beauty
        for k in range(0, int(n[-i])): # next digit
            if k == 7 or k == 4:
                if j == 0: continue
                d[i][j][0] += d[i - 1][j - 1][0] + d[i - 1][j - 1][1]
            else:
                d[i][j][0] += d[i - 1][j][0] + d[i - 1][j][1]
        x = 1 if n[-i] in ['4', '7'] else 0
        d[i][j][0] += 0 if j - x < 0 else d[i - 1][j - x][0]
        d[i][j][1] += 0 if j - x < 0 else d[i - 1][j - x][1]
        for k in range(int(n[-i]) + 1, 10):
            if k == 7 or k == 4:
                if j == 0: continue
                d[i][j][1] += d[i - 1][j - 1][0] + d[i - 1][j - 1][1]
            else:
                d[i][j][1] += d[i - 1][j][0] + d[i - 1][j][1]
cnt = [0 for i in range(12)]
for j in range(len(n) + 1):
    cnt[j] += d[len(n)][j][0]
cnt[0] -= 1
ans = 0
for i in range(1, len(n) + 1):
    ans = (ans + cnt[i] * go(i, 0)) % mod
print ans