PAINTPOI - Painting Points

Two players play the following game. The first player paints a point on the plane red. The second player paints k uncoloured points on the plane green. The first player paints an uncoloured point on the plane red. The second player paints k uncoloured points on the plane green. And so on. The first player wins if there are three red points which form an equilateral triangle. The second player wins if it is not possible within a finite number of moves. Assume he plays perfectly to prevent or delay the first player from winning. Given k, determine the minimum number of moves it takes for the first player to force a win. If it's not possible for the first player to win, output -1.

The Input

Each line of input has an even integer k, 0 < k <= 1000000.

The Output

For each line of input, output the answer on one line.

Example

Input:
10

Input:
12

Problem setter --- Wu, Xiaogang


Added by:Chen Xiaohong
Date:2007-11-06
Time limit:0.100s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:ADA95 ASM32 BASH BF C CSHARP CPP C99 CLPS LISP sbcl LISP clisp D FORTRAN HASK ICON ICK JAVA LUA NEM NICE OCAML PAS-GPC PAS-FPC PERL PHP PIKE PRLG-swi PYTHON RUBY SCM guile SCM qobi ST WHITESPACE

© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.