#### Registered Users Only

Please login to utilize this feature.

Do note that this website only supports submissions in C++.

IOI 2015 will be held in Kazakhstan. "Kazakh" can be written as "QAZAQ", which is a palindrome. Once JOI-kun learned about this, he started to like palindromes a lot and now tries to make palindromes out of anything that he sees.

The string that JOI-kun is currently looking at has **N** characters. Each character is represented by a number from 1 to **C**, so the string is represented by a sequence of integers **S _{}** = (

**S**,

_{1}**S**,

_{2}**S**, …,

_{3}**S**). Let the substring from

_{N}**i**to

**j**(1 ≤

**i**≤

**j**≤

**N**) of characters from the original string be denoted as

*substr*(

**i**,

**j**) = (

**S**,

_{i}**S**, …,

_{i+1}**S**). If reversing

_{j}*substr*(

**i**,

**j**) does not change it, that is, (

**S**,

_{i}**S**, …,

_{i+1}**S**) = (

_{j}**S**,

_{j}**S**, …,

_{j-1}**S**), then

_{i}*substr*(

**i**,

**j**) is a palindrome.

JOI-kun is constructing palindromes using the following procedure:

- First, pick a substring of
**S**. Call this substring_{}**T**. - Sort substring
**T**in increasing order and call the sorted result**T'**._{} - Replace
**T**with**T'**in**S**to obtain_{}**S'**. In otherwords, if_{}**T**was chosen to be*substr*(**i**,**j**), then**S'**= (_{}**S**,_{1}**S**, …,_{2}**S**,_{i-1}**T'**,_{i}**T'**, …_{i+1}**T'**,_{j}**S**,_{j+1}**S**, …,_{j+2}**S**)._{N} - Check if any substring of
**S'**is now a palindrome._{}

JOI-kun wants to make the longest palindrome possible to create using this procedure.

Given JOI-kun's string, find the length of the longest palindrome JOI-kun can produce in the string using the procedure above.

### Input

Read from standard input.

- On the first line, there are two integers,
**N**and**C**.**N**represents the length of JOI-kun's string**S**and_{}**C**is an upper limit of the character values in**S**._{} - The next
**N**lines represent the string**S**. The ith line contains one integer_{}**S**, the ith value in the sequence_{i}**S**._{}

### Output

Print one line with one integer to standard output. The integer should be the length of the longest palindrome that JOI-kun can produce in the string using the procedure above.

### Constraints

All test cases satisfy the following constraints:

- 1 ≤
**N**≤ 3 000. - 1 ≤
**C**≤ 3 000. - 1 ≤
**S**≤_{i}**C**(1 ≤**i**≤**N**).

### Subtasks

Subtask 1 (10 points):

The following constraints are satisfied:

**N**≤ 50.**C**≤ 50.

Subtask 2 (90 points):

No further constraints.

### Sample Input 1

```
12 26
26
17
17
17
1
26
1
17
19
20
1
14
```

### Sample Output 1

```
8
```

### Explanation

In this example with **N** = 12 and **C** = 26, the sequence **S _{}** = (26, 17, 17, 17, 1, 26, 1, 17, 19, 20, 1, 14). Sorting

*substr*(4, 8) yields

**S'**= (26, 17, 17, 1, 1, 17, 17, 26, 19, 20, 1, 14), in which

_{}*substr*(1, 8) is a palindrome. This palindrome has length 8 and is the longest palindrome possible to create.

### Sample Input 2

```
4 3
1
2
3
2
```

### Sample Output 2

```
3
```

### Explanation

In this example, **S _{}** = (1, 2, 3, 2). Sorting

*substr*(1, 1) yields

**S'**= (1, 2, 3, 2) =

_{}**S**. The longest palindrome in

_{}**S'**is

_{}*substr*(2, 4) which has length 3. This is the longest palindrome possible to create.

### Tags

### Subtasks and Limits

Subtask | Score | #TC | Time | Memory | Scoring |
---|---|---|---|---|---|

1 | 10 | 37 | 1s | 256MB | Minimum |

2 | 90 | 30 | 1s | 256MB | Minimum |

3 | 0 | 2 | 1s | 256MB | Minimum |

### Judge Compile Command

g++ ans.cpp -o aaqqz -Wall -static -O2 -lm -m64 -s -w -std=gnu++14 -fmax-errors=512