How many balanced ternary
Easy
Execution time limit is 1 second
Runtime memory usage limit is 64 megabytes
A ternary representation is considered balanced if it has an equal number of even and odd digits (where 0 is regarded as an even digit) and no prefix of the representation has more even digits than odd digits.
Given a number N, your task is to calculate the total number of balanced ternary representations of length N. The result should be presented modulo 1000000009 (10^9
+9).
Constraints
0 < N ≤
10^6
Input
The input consists of a single line containing the integer N.
Output
Output a single line containing the answer to the problem.
Examples
Input #1
Answer #1
Submissions 34
Acceptance rate 50%