The CS Nerd knows that playing music can impress girls, so he decides to learn how to play some passionate piano solos in order to impress the girl. He thinks that pieces with fast moving notes are fun to play and will make the girl think he is a piano virtuoso. In particular, he has a liking for the super chord.
A piano's notes are numbered starting from , from the left side. A super chord is formed as follows:
- Choose the first note of the chord. This can be any note.
- Repeat the following steps from the starting note: Jump right notes, then notes, then notes, then notes.
- These steps can be repeated in the reverse order from the starting note by jumping left (i.e. left down , then , then , then ).
A consecutive sequence of notes is considered to be a super sequence if every single note in the sequence is part of the same super chord. For example, the sequences and are super sequences formed using the super chord starting from note .
The CS Nerd finds a manuscript with notes on it; the note on the manuscript corresponds to note on the piano. He wants to know the length of the longest super sequence. Since the manuscript is old, the CS Nerd is allowed to change up to notes. Can you help the CS Nerd?
Constraints
For 20% of the points, and .
For an additional 30% of the points, .
Input Specification
The first line of input will contain two space-separated integers: and .
lines of input follow. The line will contain .
Output Specification
On a single line, output the length of the longest super sequence after the CS Nerd changes up to notes.
Sample Input
5 1
3
4
2
5
8
Sample Output
4
Explanation for Sample Output
The CS Nerd can change the note from to . By doing this, the continuous subsequence of notes starting from the note are all part of a super chord starting from note .
Comments
Does the super chord have to start from the lowest note, or can it start from any note. IE: super chord 1 = 1 5 8 11 13. Is 5 8 11 a super chord?
How is 11, 5, 1, 1, 17, 32 a super sequence?
All of the notes are in the same super chord.