#include <bits/stdc++.h>
using namespace std;
int dp[102][102];
int memo[102][102][102];
int n, T, a[102], cont[102], in[102], jump[102];
int solve(int rep, int pos, int best) {
  if (rep == T || rep > n) return 0;
  int &ret = memo[rep][pos][best];
  if (ret == -1) {
    ret = best * (T - rep);
    if (jump[pos] != -1) ret = max(ret, solve(rep, jump[pos], best));
    for (int p2 = pos; p2 < n; ++p2) {
      if (a[p2] >= a[pos]) {
        ret =
            max(ret, dp[pos][p2] + solve(rep + 1, in[p2],
                                         max(best, max(cont[pos], cont[p2]))));
      }
    }
  }
  return ret;
}
int main() {
  cin >> n >> T;
  for (int i = 0; i < n; ++i) cin >> a[i];
  memset(dp, -1, sizeof dp);
  for (int i = 0; i < n; ++i) {
    dp[i][i] = 1;
    for (int j = i; j + 1 < n; ++j) {
      if (dp[i][j] != -1) {
        for (int k = j + 1; k < n; ++k) {
          if (a[k] >= a[j] && (dp[i][k] == -1 || 1 + dp[i][j] > dp[i][k])) {
            dp[i][k] = 1 + dp[i][j];
          }
        }
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j)
      if (a[i] == a[j]) ++cont[i];
    for (int j = 0; j < n; ++j)
      if (a[i] == a[j]) {
        in[i] = j;
        break;
      }
    jump[i] = -1;
    for (int j = 0; j < n; ++j)
      if (a[j] > a[i] && (jump[i] == -1 || a[j] < a[jump[i]])) {
        jump[i] = j;
      }
  }
  memset(memo, -1, sizeof memo);
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    ans = max(ans, solve(0, i, 0));
  }
  cout << ans << endl;
  return 0;
}

### Prompt

Your challenge is to write 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;
int dp[102][102];
int memo[102][102][102];
int n, T, a[102], cont[102], in[102], jump[102];
int solve(int rep, int pos, int best) {
  if (rep == T || rep > n) return 0;
  int &ret = memo[rep][pos][best];
  if (ret == -1) {
    ret = best * (T - rep);
    if (jump[pos] != -1) ret = max(ret, solve(rep, jump[pos], best));
    for (int p2 = pos; p2 < n; ++p2) {
      if (a[p2] >= a[pos]) {
        ret =
            max(ret, dp[pos][p2] + solve(rep + 1, in[p2],
                                         max(best, max(cont[pos], cont[p2]))));
      }
    }
  }
  return ret;
}
int main() {
  cin >> n >> T;
  for (int i = 0; i < n; ++i) cin >> a[i];
  memset(dp, -1, sizeof dp);
  for (int i = 0; i < n; ++i) {
    dp[i][i] = 1;
    for (int j = i; j + 1 < n; ++j) {
      if (dp[i][j] != -1) {
        for (int k = j + 1; k < n; ++k) {
          if (a[k] >= a[j] && (dp[i][k] == -1 || 1 + dp[i][j] > dp[i][k])) {
            dp[i][k] = 1 + dp[i][j];
          }
        }
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j)
      if (a[i] == a[j]) ++cont[i];
    for (int j = 0; j < n; ++j)
      if (a[i] == a[j]) {
        in[i] = j;
        break;
      }
    jump[i] = -1;
    for (int j = 0; j < n; ++j)
      if (a[j] > a[i] && (jump[i] == -1 || a[j] < a[jump[i]])) {
        jump[i] = j;
      }
  }
  memset(memo, -1, sizeof memo);
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    ans = max(ans, solve(0, i, 0));
  }
  cout << ans << endl;
  return 0;
}

```