
Tiger's engineering professor has given a surprise test to the entire class! For this test, students are given some tables and are required to build a tower using those tables.
The tower can be formed by stacking a table onto two other tables. If tables are viewed length-wise, 2 legs of the table are on one table below and the other 2 legs are on the other table below.
Each table has a weight of
Many of the
Tiger wants to build the highest table tower that he can to impress his professor and the other students. Can you help him determine what that height will be?
Constraints
For all subtasks:
Subtask 1 [10%]
All values of
Subtask 2 [15%]
Subtask 3 [15%]
Subtask 4 [10%]
Subtask 5 [50%]
No additional constraints.
Input Specification
The first line contains
The next line contains the integer
The following line contains
It is guaranteed that in any non-collapsing tower, a table's apparent weight is always an integer.
Output Specification
The maximum height of a table tower. This is the number of layers in the largest table tower.
Sample Input
102
3
51 1 51
Sample Output
2
Comments