Hawawa College Student-chan Goes to Hawaii~

Interview

Time limit1sMemory limit256 MB

Summary
Count the ways to start at island 1 and visit all n islands exactly once using steps +1, +2, or -1 to new islands, modulo 1,000,000,009.
Level

Medium7 of 10

Topics
Dynamic programming, Math, Recursion
Solved
No attempts yet

Problem

Hawawawa... The college student Raga likes the phrase "hawawa," you see. Raga, who always says "hawawa" at the end of every sentence, has decided to take a trip to Hawaii, which sounds similar to her beloved hawawa! Hawawawawa... So Raga is looking at Google Maps and making plans for a Hawaii trip...

Because Hawaii is an island chain, Raga travels along the chain and visits every island... Hawawawa... An island chain means islands that formed along a line of heat, and for convenience we say that Hawaii's n islands are arranged in a single row... In this case, the trip must start at the first island, and there are three ways to travel along the chain...

  1. After seeing some island, you can go straight to the very next island...
  2. After seeing some island, you can skip one island and go to the island after that...
  3. After seeing some island, you can go to the previous island...

Hawawa... Raga wants to see all n islands of Hawaii... Also, since Raga gets bored easily, she does not want to visit an island she has already visited... Given n islands, find how many ways Raga can travel through Hawaii...

Hawawawa... But you ask why I'm writing in this style when I'm not even Raga? Hawawa, Raga's friend-chan has caught the speech style too...

Input

The first line gives the number of islands n in the Hawaii chain (1 ≤ n ≤ 50,000), hawawa. Hawawa! Since the answer can be large, print it modulo 1,000,000,009!

Output

On the first line, print the number of ways Raga can travel, hawawa.

Examples2

  1. Example 1

    Input
    2
    
    Expected output
    1
    
  2. Example 2

    Input
    5
    Expected output
    4