Gift

Count sequences of length N that split into blocks where each block is 0,1,...,L-1 with L at most K, modulo 1e9+7.

Medium7Dynamic programmingCombinatoricsMathPrefix sumNo attempts yetTime limit2sMemory limit512 MB

Problem

Karev really likes simple sequences of length at most KK. A simple sequence of length LL is the sequence of the numbers from 00 to L1L-1 written in this order. For example, {0}\{0\}, {0,1,2,3}\{0,1,2,3\} and {0,1,2,3,4,5,6}\{0,1,2,3,4,5,6\} are simple sequences, while {1}\{1\}, {0,1,3,2}\{0,1,3,2\} and {0,1,3}\{0,1,3\} are not.

Karev's birthday is close, so Polly wants to buy a few simple sequences and concatenate them into an interesting sequence. An interesting sequence is a sequence obtained by concatenating several simple sequences, each of length at most KK. For example, let K=3K=3. Then {0,1,2,0}\{0,1,2,0\}, {0,1,0,1}\{0,1,0,1\}, {0,0,0}\{0,0,0\} and {0,1,2}\{0,1,2\} are interesting sequences, while {0,1,2,3}\{0,1,2,3\}, {0,1,1}\{0,1,1\} and {0,0,2}\{0,0,2\} are not.

Polly has so many sequences to choose from that she cannot decide which one to pick, and she wonders how many choices she really has.

Given KK, the maximum length of a simple sequence Polly can buy, and NN, the length of the interesting sequence she wants to form, write a program that counts the different interesting sequences she could make. This number can be very large, so output it modulo 109+710^9+7.

Input

The first line contains two integers NN and KK, in this order, separated by a space.

Output

Print on the first line the number of different interesting sequences Polly can make, modulo 109+710^9+7.

Constraints

  • 1KN2×1061 \le K \le N \le 2 \times 10^6

Note

For N=4N=4 and K=3K=3 the possible interesting sequences are {0,0,0,0}\{0,0,0,0\}, {0,0,0,1}\{0,0,0,1\}, {0,0,1,0}\{0,0,1,0\}, {0,0,1,2}\{0,0,1,2\}, {0,1,0,0}\{0,1,0,0\}, {0,1,0,1}\{0,1,0,1\} and {0,1,2,0}\{0,1,2,0\}, so the answer is 7.