#include <bits/stdc++.h>
using namespace std;
const int M = 50010;
const int maxn = M * 100;
int n, t, a[maxn], num[330];
int maxv[330];
int getm(int x) {
  int ans = 0;
  for (int i = x; i; i -= i & (-i)) ans = max(ans, maxv[i]);
  return ans;
}
void ins(int x, int c) {
  for (int i = x; i < 330; i += i & (-i)) maxv[i] = max(maxv[i], c);
}
int gao(int t) {
  for (int i = 0; i < n; i++) {
    for (int j = 0, k = i + n; j < t - 1; j++, k += n) a[k] = a[i];
  }
  n *= t;
  memset(maxv, 0, sizeof maxv);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int tmp = getm(a[i]) + 1;
    ins(a[i], tmp);
  }
  return getm(300);
}
int main() {
  while (cin >> n >> t) {
    memset(num, 0, sizeof num);
    for (int i = 0; i < n; i++) {
      scanf("%d", a + i);
      num[a[i]]++;
    }
    int ans = gao(min(t, M));
    int mav = 0;
    for (int i = 0; i < 330; i++) mav = max(mav, num[i]);
    ans += mav * max(t - M, 0);
    cout << ans << endl;
  }
  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>
using namespace std;
const int M = 50010;
const int maxn = M * 100;
int n, t, a[maxn], num[330];
int maxv[330];
int getm(int x) {
  int ans = 0;
  for (int i = x; i; i -= i & (-i)) ans = max(ans, maxv[i]);
  return ans;
}
void ins(int x, int c) {
  for (int i = x; i < 330; i += i & (-i)) maxv[i] = max(maxv[i], c);
}
int gao(int t) {
  for (int i = 0; i < n; i++) {
    for (int j = 0, k = i + n; j < t - 1; j++, k += n) a[k] = a[i];
  }
  n *= t;
  memset(maxv, 0, sizeof maxv);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int tmp = getm(a[i]) + 1;
    ins(a[i], tmp);
  }
  return getm(300);
}
int main() {
  while (cin >> n >> t) {
    memset(num, 0, sizeof num);
    for (int i = 0; i < n; i++) {
      scanf("%d", a + i);
      num[a[i]]++;
    }
    int ans = gao(min(t, M));
    int mav = 0;
    for (int i = 0; i < 330; i++) mav = max(mav, num[i]);
    ans += mav * max(t - M, 0);
    cout << ans << endl;
  }
  return 0;
}

```