#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, t, ans;
int a[N], b[N], dp[N][301], f[N], s[N], F[N];
int main() {
  cin >> n >> t;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    f[a[i]]++;
  }
  for (int i = 1; i <= n; i++) {
    if (!s[a[i]]) {
      s[a[i]] = 1;
      F[f[a[i]]] = 1;
    }
  }
  int ind = 1, mn = min(n, t);
  for (int i = 1; i <= mn; i++) {
    while (ind != mn * n + 1) {
      if (ind % n != 0)
        b[ind] = a[ind % n];
      else
        b[ind] = a[n];
      ind++;
    }
    ind--;
  }
  for (int i = 1; i <= ind; i++) {
    for (int j = 1; j <= b[i]; j++)
      dp[i][b[i]] = max(dp[i][b[i]], dp[i - 1][b[i]] + 1);
    for (int j = 1; j <= 300; j++)
      dp[i][j] = max({dp[i][j], dp[i][j - 1], dp[i - 1][j]});
  }
  ans = dp[ind][300];
  if (t > n) {
    int mx1 = 0, mx2 = 0;
    for (int i = (n - 1) * n + 1; i <= ind; i++) mx1 = max(mx1, dp[i][300]);
    for (int i = (n - 2) * n + 1; i <= (n - 1) * n; i++)
      mx2 = max(mx2, dp[i][300]);
    ans += (t - n) * (mx1 - mx2);
  }
  cout << ans << "\n";
}

### Prompt

Please formulate a CPP solution to the following problem:

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;
const int N = 1e5 + 10;
int n, t, ans;
int a[N], b[N], dp[N][301], f[N], s[N], F[N];
int main() {
  cin >> n >> t;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    f[a[i]]++;
  }
  for (int i = 1; i <= n; i++) {
    if (!s[a[i]]) {
      s[a[i]] = 1;
      F[f[a[i]]] = 1;
    }
  }
  int ind = 1, mn = min(n, t);
  for (int i = 1; i <= mn; i++) {
    while (ind != mn * n + 1) {
      if (ind % n != 0)
        b[ind] = a[ind % n];
      else
        b[ind] = a[n];
      ind++;
    }
    ind--;
  }
  for (int i = 1; i <= ind; i++) {
    for (int j = 1; j <= b[i]; j++)
      dp[i][b[i]] = max(dp[i][b[i]], dp[i - 1][b[i]] + 1);
    for (int j = 1; j <= 300; j++)
      dp[i][j] = max({dp[i][j], dp[i][j - 1], dp[i - 1][j]});
  }
  ans = dp[ind][300];
  if (t > n) {
    int mx1 = 0, mx2 = 0;
    for (int i = (n - 1) * n + 1; i <= ind; i++) mx1 = max(mx1, dp[i][300]);
    for (int i = (n - 2) * n + 1; i <= (n - 1) * n; i++)
      mx2 = max(mx2, dp[i][300]);
    ans += (t - n) * (mx1 - mx2);
  }
  cout << ans << "\n";
}

```