Олимпиадный тренинг

Задача 38351. Gather the numbers


Vasya had a set of cubes at his disposal. Vasya decided to write a number on each side of each cube and then use the cubes to add numbers from them. Vasya wants to write numbers in such a way that he can add any number from 1 to some number K. Calculate the maximum K, up to which Vasya will be able to lay out all the numbers, if Vasya has N cubes at his disposal. Note that if the number 6 is written on some face of a die, then the same face can also be used as the number 9 by simply flipping the corresponding die.

When laying out the number, Vasya is not obliged to use all the cubes. Leading zeros are not needed in numbers.

Let's look at some examples.

Let N=1. Then, by writing numbers from 1 to 6 on the faces of the cube, Vasya will be able to lay out numbers from 1 to 6. Thus, K=6.

Let N=2. Then, by writing the numbers from 1 to 6 on the faces of one cube, and the numbers 0, 1, 2, 3, 7, 8 on the faces of another, Vasya will be able to lay out any number from 1 to 43.

Input
The input file contains one number N (1≤N≤1000000).

Imprint
In the output file, output the maximum value of K such that, having N cubes, Vasya can write numbers on their faces in such a way that it would be possible to lay out any number from 1 to K.
Examples
# Input Output
1 1 6
2 2 43