Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/zinapoya

Staircase

Medium 1000 ms 64 MB 45%
Share

A staircase has $n$ steps. In one move you may climb $1$, $2$ or $3$ steps. Find the number of ways to climb from the bottom (step $0$) to exactly step $n$. Two ways are different if their sequences of moves differ.

Ways to reach the top of the staircase with moves of one, two or three steps

Input

One positive integer $n$.

Output

One integer — the number of ways modulo $10^{9} + 7$.

Note

$1 \le n \le 10^{6}$

Examples

Input #1
3
Output #1
4
Input #2
4
Output #2
7

Sign in to submit a solution

Signing up is free and takes a minute.