LearnPy Hub
← Arena
AdvancedRating 1800

Tribonacci for Huge n

T₀ = 0, T₁ = 1, T₂ = 1 and Tₙ = Tₙ₋₁ + Tₙ₋₂ + Tₙ₋₃. Print Tₙ modulo 1 000 000 007. n can be 10¹⁸, so use fast matrix powers.

Input

One integer n (0 ≤ n ≤ 10¹⁸).

Output

One integer.

Sample 1

Input
0
Output
0

Sample 2

Input
1
Output
0
solution.py
Output appears here
Tribonacci for Huge n · Python Arena problem · LearnPy Hub