#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
int a[104 * 104];
int dp[104 * 104];
int n, m;
int tt;
int b[104];
int pre() {
  int i, j;
  for (j = 1; j <= n; j++) b[j] = a[j];
  sort(b + 1, b + n + 1);
  int ans = 1;
  int temp = 1;
  for (i = 2; i <= n; i++) {
    if (b[i] == b[i - 1]) {
      temp++;
      ans = max(ans, temp);
    } else {
      ans = max(temp, ans);
      temp = 1;
    }
  }
  return ans;
}
int solve() {
  int all = n * tt;
  for (int i = n + 1; i <= all; i++) a[i] = a[i - n];
  int len = 1;
  dp[0] = a[1];
  for (int i = 2; i <= all; i++) {
    int pos = upper_bound(dp, dp + len, a[i]) - dp;
    dp[pos] = a[i];
    if (pos >= len) len++;
  }
  return len;
}
int main() {
  int i, j;
  while (~scanf("%d%d", &n, &m)) {
    for (i = 1; i <= n; i++) scanf("%d", &a[i]);
    tt = min(n, m);
    int le = pre();
    int ri = solve();
    if (tt < m) {
      ri += (m - tt) * le;
    }
    printf("%d\n", ri);
  }
  return 0;
}

### Prompt

Generate 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>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
int a[104 * 104];
int dp[104 * 104];
int n, m;
int tt;
int b[104];
int pre() {
  int i, j;
  for (j = 1; j <= n; j++) b[j] = a[j];
  sort(b + 1, b + n + 1);
  int ans = 1;
  int temp = 1;
  for (i = 2; i <= n; i++) {
    if (b[i] == b[i - 1]) {
      temp++;
      ans = max(ans, temp);
    } else {
      ans = max(temp, ans);
      temp = 1;
    }
  }
  return ans;
}
int solve() {
  int all = n * tt;
  for (int i = n + 1; i <= all; i++) a[i] = a[i - n];
  int len = 1;
  dp[0] = a[1];
  for (int i = 2; i <= all; i++) {
    int pos = upper_bound(dp, dp + len, a[i]) - dp;
    dp[pos] = a[i];
    if (pos >= len) len++;
  }
  return len;
}
int main() {
  int i, j;
  while (~scanf("%d%d", &n, &m)) {
    for (i = 1; i <= n; i++) scanf("%d", &a[i]);
    tt = min(n, m);
    int le = pre();
    int ri = solve();
    if (tt < m) {
      ri += (m - tt) * le;
    }
    printf("%d\n", ri);
  }
  return 0;
}

```