#include <bits/stdc++.h>
using namespace std;
int n, t, suml, sumr, d[100000], dl[100000], dr[100000], a[100000], b[100000],
    ans = 0;
int main() {
  cin >> n >> t;
  if (t < 200) {
    for (int i = 0; i < n * t; i++)
      if (i >= n)
        a[i] = a[i - n];
      else
        cin >> a[i];
    for (int i = 0; i < n * t; i++)
      for (int j = 0; j < i; j++)
        if (a[i] >= a[j]) d[i] = max(d[i], d[j] + 1);
    for (int i = 0; i < n * t; i++) ans = max(ans, d[i]);
    cout << ans + 1;
  } else {
    for (int i = 0; i < n * 100; i++)
      if (i >= n)
        a[i] = a[i - n];
      else {
        cin >> a[i];
        b[a[i]]++;
      }
    for (int i = 0; i < n * 100; i++)
      for (int j = 0; j < i; j++)
        if (a[i] >= a[j]) dl[i] = max(dl[i], dl[j] + 1);
    for (int i = n * 100 - 1; i >= 0; i--)
      for (int j = i + 1; j < n * 100; j++)
        if (a[i] <= a[j]) dr[i] = max(dr[i], dr[j] + 1);
    for (int i = 0; i < n; i++) {
      suml = 0;
      for (int j = 0; j <= n * 100; j++)
        if (a[j] <= a[i]) suml = max(suml, dl[j] + 1);
      sumr = 0;
      for (int j = 0; j <= n * 100; j++)
        if (a[j] >= a[i]) sumr = max(sumr, dr[j] + 1);
      ans = max(ans, suml + sumr + (b[a[i]] * (t - 200)));
    }
    cout << ans;
  }
}

### Prompt

Develop a solution in Cpp to the problem described below:

You are given an array of positive integers a1, a2, ..., an × T of length n × T. We know that for any i > n it is true that ai = ai - n. Find the length of the longest non-decreasing sequence of the given array.

Input

The first line contains two space-separated integers: n, T (1 ≤ n ≤ 100, 1 ≤ T ≤ 107). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 300).

Output

Print a single number — the length of a sought sequence.

Examples

Input

4 3
3 1 4 2


Output

5

Note

The array given in the sample looks like that: 3, 1, 4, 2, 3, 1, 4, 2, 3, 1, 4, 2. The elements in bold form the largest non-decreasing subsequence. 

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, t, suml, sumr, d[100000], dl[100000], dr[100000], a[100000], b[100000],
    ans = 0;
int main() {
  cin >> n >> t;
  if (t < 200) {
    for (int i = 0; i < n * t; i++)
      if (i >= n)
        a[i] = a[i - n];
      else
        cin >> a[i];
    for (int i = 0; i < n * t; i++)
      for (int j = 0; j < i; j++)
        if (a[i] >= a[j]) d[i] = max(d[i], d[j] + 1);
    for (int i = 0; i < n * t; i++) ans = max(ans, d[i]);
    cout << ans + 1;
  } else {
    for (int i = 0; i < n * 100; i++)
      if (i >= n)
        a[i] = a[i - n];
      else {
        cin >> a[i];
        b[a[i]]++;
      }
    for (int i = 0; i < n * 100; i++)
      for (int j = 0; j < i; j++)
        if (a[i] >= a[j]) dl[i] = max(dl[i], dl[j] + 1);
    for (int i = n * 100 - 1; i >= 0; i--)
      for (int j = i + 1; j < n * 100; j++)
        if (a[i] <= a[j]) dr[i] = max(dr[i], dr[j] + 1);
    for (int i = 0; i < n; i++) {
      suml = 0;
      for (int j = 0; j <= n * 100; j++)
        if (a[j] <= a[i]) suml = max(suml, dl[j] + 1);
      sumr = 0;
      for (int j = 0; j <= n * 100; j++)
        if (a[j] >= a[i]) sumr = max(sumr, dr[j] + 1);
      ans = max(ans, suml + sumr + (b[a[i]] * (t - 200)));
    }
    cout << ans;
  }
}

```