How many balanced ternary#10055

How many balanced ternary

1 second
64 megabytes
Easy

A ternary representation is considered balanced if it has an equal number of even and odd digits (where is regarded as an even digit) and no prefix of the representation has more even digits than odd digits.

Given a number (0 < N \le 10^6), your task is to calculate the total number of balanced ternary representations of length . The result should be presented modulo 1000000009 (10^9+9).

Input

The input consists of a single line containing the integer .

Output

Output a single line containing the answer to the problem.

Examples

Example 1

Loading
Loading