This page is still under construction.

Parts of this page are still being built. What you see may change.

Good Sets

Time limit2sMemory limit512 MB

Summary
Count nonempty subsets of {1,...,N} whose decimal digits, pooled together, use each digit 0-9 at most once.
Level

Medium6 of 10

Topics
Bit manipulation, Combinatorics, Dynamic programming
Solved
No attempts yet

Problem

Let SS be the set of the integers from 1 to NN.

Write a program that counts how many subsets of SS are good sets.

A subset is a good set when you write every number it contains in decimal, collect all of those digits together, and each of the digits 0 to 9 appears at most once. The empty set is not counted.

For example, {12, 345, 67890} and {47, 109} are good sets, while {147, 342} is not a good set because the digit 4 appears twice.

Input

The first line contains NN. (1≤N≤1091 \le N \le 10^9)

Output

Print the number of good sets among the subsets of SS, modulo 1,000,000,007.

Examples2

  1. Example 1

    Input
    3
    
    Expected output
    7
    
  2. Example 2

    Input
    10
    
    Expected output
    767