#include <bits/stdc++.h>
using namespace std;
const int MAX = 105;
int arr[MAX], ma[MAX][MAX], dp[MAX][MAX], path[MAX][MAX], cont[305];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, t, rep = 0, idx = 0;
  cin >> n >> t;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    cont[arr[i]]++;
    if (cont[arr[i]] > rep) {
      rep = max(rep, cont[arr[i]]);
      idx = i;
    }
  }
  for (int i = 0; i < n; i++) {
    ma[i][i] = 1;
    for (int j = 0; j < n; j++) {
      if (arr[j] < arr[i]) {
        ma[i][j] = INT_MIN;
        continue;
      }
      int r = 0;
      for (int k = 0; k < j; k++) {
        if (arr[k] <= arr[j]) {
          r = max(r, ma[i][k]);
        }
      }
      ma[i][j] = r + 1;
    }
  }
  int ans = 0;
  for (int i = 1; i <= min(t, n + 1); i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
        if (dp[i][j] < dp[i - 1][k] + ma[k][j]) {
          dp[i][j] = max(dp[i][j], dp[i - 1][k] + ma[k][j]);
          path[i][j] = k;
        }
        ans = max(ans, dp[i][j]);
      }
    }
  }
  if (t < n + 1)
    cout << ans;
  else {
    for (int i = 0; i < n; i++) {
      if (dp[n + 1][i] == ans) {
        int row = n + 1;
        int col = i;
        while (path[row][col] != col) {
          col = path[row][col];
          row--;
        }
        ans += ma[col][col] * (t - n - 1);
        break;
      }
    }
    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;
const int MAX = 105;
int arr[MAX], ma[MAX][MAX], dp[MAX][MAX], path[MAX][MAX], cont[305];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, t, rep = 0, idx = 0;
  cin >> n >> t;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    cont[arr[i]]++;
    if (cont[arr[i]] > rep) {
      rep = max(rep, cont[arr[i]]);
      idx = i;
    }
  }
  for (int i = 0; i < n; i++) {
    ma[i][i] = 1;
    for (int j = 0; j < n; j++) {
      if (arr[j] < arr[i]) {
        ma[i][j] = INT_MIN;
        continue;
      }
      int r = 0;
      for (int k = 0; k < j; k++) {
        if (arr[k] <= arr[j]) {
          r = max(r, ma[i][k]);
        }
      }
      ma[i][j] = r + 1;
    }
  }
  int ans = 0;
  for (int i = 1; i <= min(t, n + 1); i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
        if (dp[i][j] < dp[i - 1][k] + ma[k][j]) {
          dp[i][j] = max(dp[i][j], dp[i - 1][k] + ma[k][j]);
          path[i][j] = k;
        }
        ans = max(ans, dp[i][j]);
      }
    }
  }
  if (t < n + 1)
    cout << ans;
  else {
    for (int i = 0; i < n; i++) {
      if (dp[n + 1][i] == ans) {
        int row = n + 1;
        int col = i;
        while (path[row][col] != col) {
          col = path[row][col];
          row--;
        }
        ans += ma[col][col] * (t - n - 1);
        break;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

```