Under construction

Still being built. Things may change

Tiling a 3-by-N Wall

Interview

Time limit2sMemory limit128 MB

Summary
Count the number of ways to tile a 3-by-N wall using 2x1 dominoes, for N up to 30.
Level

Medium4 of 10

Topics
Dynamic programming, Combinatorics
Solved
No attempts yet

Problem

There is a rectangular wall with height 3 and width NN. You want to cover the entire wall with domino tiles of size 2×12\times1 or 1×21\times2.

Tiles must not overlap, and no tile may extend outside the wall. Find the number of different ways to tile the wall.

Input

The first line contains an integer NN. (1≤N≤30)(1 \le N \le 30)

Output

Print the number of ways to tile a 3×N3\times N wall.

Hint

The figure below shows one tiling of a 3×123\times12 wall.

Examples1

  1. Example 1

    Input
    2
    
    Expected output
    3