Candies

아직 제출이 없습니다시간 제한1초메모리 제한1024 MB

문제

Grammy has a circular array a_1,a_2,,a_na\_1, a\_2, \ldots, a\_n. You can do the following operations several (possibly zero) times in any order:

  • Choose two adjacent positions with the same number, and erase them.
  • Choose two adjacent positions such that the numbers on these positions add up to a special number xx, and erase them.

After each time you do an operation successfully, Grammy will give you a candy. Meanwhile, the remaining parts of the array will be concatenated. For example, after deleting the third and fourth element of the array, the second element and the fifth element will become adjacent.

Find the maximum number of candies you can get.

Two positions uu and vv (u\<vu\<v) are adjacent if and only if u+1=vu+1=v or u=1u=1 and v=Lv=L, where LL is the length of the remaining array.

입력

The first line contains two integers nn and xx (1n1051 \leq n \leq 10^5, 1x1091 \leq x \leq 10^9) denoting the length of the array and the special number xx.

The second line contains nn integers a_1,a_2,,a_na\_1, a\_2,\ldots, a\_n (1a_i1091 \leq a\_i \leq 10^9) denoting the numbers in the circular array.

출력

Output an integer denoting the maximum number of candies you can get.