#include <bits/stdc++.h>
using namespace std;
const int N = 1 << 20;
int f[N], n, T, a[N], bit[512], g[N];
void update(int i, int x) {
  for (; i < 512; i += i & -i) bit[i] = max(bit[i], x);
}
int get(int i) {
  int res = 0;
  for (; i > 0; i -= i & -i) res = max(res, bit[i]);
  return res;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  srand(time(0));
  cin >> n >> T;
  for (int i = 0; i < int(n); i++) cin >> a[i];
  for (int i = 0; i < int(n * 10000); i++) a[i] = a[i % n];
  if (T < 10000) {
    int fmax = 0;
    for (int i = 0; i < int(n * T); i++) {
      f[i] = get(a[i]) + 1;
      update(a[i], f[i]);
      if (f[i] > f[fmax]) fmax = i;
    }
    cout << f[fmax] << endl;
    return 0;
  }
  int m = 200;
  int ans = 0;
  for (int v = 0; v < int(n); v++) {
    memset(bit, 0, sizeof(bit));
    int fmax = 0, gmax = n * m - 1;
    f[fmax] = g[gmax] = 0;
    for (int i = 0; i < int(n * m); i++) {
      if (a[i] <= a[v]) {
        f[i] = get(a[i]) + 1;
        update(a[i], f[i]);
        if (f[i] > f[fmax]) fmax = i;
      }
    }
    memset(bit, 0, sizeof(bit));
    for (int i = (n * m - 1); i >= (0); i--) {
      if (a[i] >= a[v]) {
        g[i] = get(400 - a[i]) + 1;
        update(400 - a[i], g[i]);
        if (g[i] > g[gmax]) gmax = i;
      }
    }
    int cnt = 0;
    for (int i = 0; i < int(n); i++)
      if (a[i] == a[v]) cnt++;
    ans = max(ans, f[fmax] + g[gmax] + cnt * (T - 2 * m));
  }
  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 N = 1 << 20;
int f[N], n, T, a[N], bit[512], g[N];
void update(int i, int x) {
  for (; i < 512; i += i & -i) bit[i] = max(bit[i], x);
}
int get(int i) {
  int res = 0;
  for (; i > 0; i -= i & -i) res = max(res, bit[i]);
  return res;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  srand(time(0));
  cin >> n >> T;
  for (int i = 0; i < int(n); i++) cin >> a[i];
  for (int i = 0; i < int(n * 10000); i++) a[i] = a[i % n];
  if (T < 10000) {
    int fmax = 0;
    for (int i = 0; i < int(n * T); i++) {
      f[i] = get(a[i]) + 1;
      update(a[i], f[i]);
      if (f[i] > f[fmax]) fmax = i;
    }
    cout << f[fmax] << endl;
    return 0;
  }
  int m = 200;
  int ans = 0;
  for (int v = 0; v < int(n); v++) {
    memset(bit, 0, sizeof(bit));
    int fmax = 0, gmax = n * m - 1;
    f[fmax] = g[gmax] = 0;
    for (int i = 0; i < int(n * m); i++) {
      if (a[i] <= a[v]) {
        f[i] = get(a[i]) + 1;
        update(a[i], f[i]);
        if (f[i] > f[fmax]) fmax = i;
      }
    }
    memset(bit, 0, sizeof(bit));
    for (int i = (n * m - 1); i >= (0); i--) {
      if (a[i] >= a[v]) {
        g[i] = get(400 - a[i]) + 1;
        update(400 - a[i], g[i]);
        if (g[i] > g[gmax]) gmax = i;
      }
    }
    int cnt = 0;
    for (int i = 0; i < int(n); i++)
      if (a[i] == a[v]) cnt++;
    ans = max(ans, f[fmax] + g[gmax] + cnt * (T - 2 * m));
  }
  cout << ans << endl;
  return 0;
}

```