#include <bits/stdc++.h>
using namespace std;
int n, t;
int orig[101];
void fillArray(vector<int>& a, int p) {
  for (int i = 0; i < p; i++) {
    if (i < n)
      a[i] = orig[i];
    else
      a[i] = a[i - n];
  }
}
int findLis(vector<int>& a, vector<int>& b, int p) {
  int maxx = 0;
  for (int i = p - 1; i >= 0; i--) {
    b[i] = 1;
    for (int j = i + 1; j < p; j++) {
      if (a[j] >= a[i]) b[i] = max(b[i], b[j] + 1);
    }
    maxx = max(b[i], maxx);
  }
  return maxx;
}
int main() {
  cin >> n >> t;
  for (int i = 0; i < n; i++) cin >> orig[i];
  if (t <= 2 * n) {
    vector<int> a(t * n);
    vector<int> b(t * n);
    fillArray(a, t * n);
    cout << findLis(a, b, t * n) << endl;
  } else {
    vector<int> a(n * n);
    fillArray(a, n * n);
    vector<int> last(n * n);
    findLis(a, last, n * n);
    vector<int> top(n * n);
    for (int i = 0; i < n * n; i++) a[i] = 310 - a[i];
    reverse(a.begin(), a.end());
    findLis(a, top, n * n);
    reverse(top.begin(), top.end());
    int maxx = -1;
    for (int i = 0; i < n; i++) {
      int cnt = 0;
      for (int j = 0; j < n; j++)
        if (orig[i] == orig[j]) cnt++;
      for (int j = 0; j < n; j++)
        if (orig[j] >= orig[i])
          maxx = max(maxx, last[j] + top[n * n - n + i] + (t - 2 * n) * cnt);
    }
    cout << maxx << endl;
  }
}

### Prompt

Please provide a cpp coded solution 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;
int orig[101];
void fillArray(vector<int>& a, int p) {
  for (int i = 0; i < p; i++) {
    if (i < n)
      a[i] = orig[i];
    else
      a[i] = a[i - n];
  }
}
int findLis(vector<int>& a, vector<int>& b, int p) {
  int maxx = 0;
  for (int i = p - 1; i >= 0; i--) {
    b[i] = 1;
    for (int j = i + 1; j < p; j++) {
      if (a[j] >= a[i]) b[i] = max(b[i], b[j] + 1);
    }
    maxx = max(b[i], maxx);
  }
  return maxx;
}
int main() {
  cin >> n >> t;
  for (int i = 0; i < n; i++) cin >> orig[i];
  if (t <= 2 * n) {
    vector<int> a(t * n);
    vector<int> b(t * n);
    fillArray(a, t * n);
    cout << findLis(a, b, t * n) << endl;
  } else {
    vector<int> a(n * n);
    fillArray(a, n * n);
    vector<int> last(n * n);
    findLis(a, last, n * n);
    vector<int> top(n * n);
    for (int i = 0; i < n * n; i++) a[i] = 310 - a[i];
    reverse(a.begin(), a.end());
    findLis(a, top, n * n);
    reverse(top.begin(), top.end());
    int maxx = -1;
    for (int i = 0; i < n; i++) {
      int cnt = 0;
      for (int j = 0; j < n; j++)
        if (orig[i] == orig[j]) cnt++;
      for (int j = 0; j < n; j++)
        if (orig[j] >= orig[i])
          maxx = max(maxx, last[j] + top[n * n - n + i] + (t - 2 * n) * cnt);
    }
    cout << maxx << endl;
  }
}

```