Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ACM-ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

D. Magic Gems

time limit per test

3 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputReziba has many magic gems. Each magic gem can be split into $$$M$$$ normal gems. The amount of space each magic (and normal) gem takes is $$$1$$$ unit. A normal gem cannot be split.

Reziba wants to choose a set of magic gems and split some of them, so the total space occupied by the resulting set of gems is $$$N$$$ units. If a magic gem is chosen and split, it takes $$$M$$$ units of space (since it is split into $$$M$$$ gems); if a magic gem is not split, it takes $$$1$$$ unit.

How many different configurations of the resulting set of gems can Reziba have, such that the total amount of space taken is $$$N$$$ units? Print the answer modulo $$$1000000007$$$ ($$$10^9+7$$$). Two configurations are considered different if the number of magic gems Reziba takes to form them differs, or the indices of gems Reziba has to split differ.

Input

The input contains a single line consisting of $$$2$$$ integers $$$N$$$ and $$$M$$$ ($$$1 \le N \le 10^{18}$$$, $$$2 \le M \le 100$$$).

Output

Print one integer, the total number of configurations of the resulting set of gems, given that the total amount of space taken is $$$N$$$ units. Print the answer modulo $$$1000000007$$$ ($$$10^9+7$$$).

Examples

Input

4 2

Output

5

Input

3 2

Output

3

Note

In the first example each magic gem can split into $$$2$$$ normal gems, and we know that the total amount of gems are $$$4$$$.

Let $$$1$$$ denote a magic gem, and $$$0$$$ denote a normal gem.

The total configurations you can have is:

- $$$1 1 1 1$$$ (None of the gems split);
- $$$0 0 1 1$$$ (First magic gem splits into $$$2$$$ normal gems);
- $$$1 0 0 1$$$ (Second magic gem splits into $$$2$$$ normal gems);
- $$$1 1 0 0$$$ (Third magic gem splits into $$$2$$$ normal gems);
- $$$0 0 0 0$$$ (First and second magic gems split into total $$$4$$$ normal gems).

Hence, answer is $$$5$$$.

Codeforces (c) Copyright 2010-2019 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: May/23/2019 11:13:13 (f3).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|