#include <bits/stdc++.h>
using namespace std;
int a[305];
int c[200010];
int f[200010], g[200010];
int cc[305], tt[305];
int n, T;
inline int lowbit(int x) { return x & (-x); }
void insert(int p, int c) {
  while (p <= 305) {
    a[p] = max(a[p], c);
    p += lowbit(p);
  }
}
int qry(int p) {
  int ans = 0;
  while (p > 0) {
    ans = max(ans, a[p]);
    p -= lowbit(p);
  }
  return ans;
}
int main() {
  int ttt = 9;
  scanf("%d%d", &n, &T);
  for (int i = 1; i <= n; i++) scanf("%d", &c[i]);
  if (T < 1000) {
    ttt++;
    int cnt = n;
    int CAS = T - 1;
    while (CAS--) {
      for (int i = 1; i <= n; i++) c[++cnt] = c[i];
    }
    n = cnt;
    memset(a, 0, sizeof a);
    int ans = 1;
    for (int i = 1; i <= n; i++) {
      f[i] = 1 + qry(c[i]);
      ans = max(ans, f[i]);
      insert(c[i], f[i]);
    }
    printf("%d\n", ans);
  } else {
    for (int i = 1; i <= n; i++) cc[c[i]]++;
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++)
        if (c[i] == c[j]) {
          tt[i - 1] = j;
          break;
        }
    ttt++;
    int cnt = n;
    int nn = n;
    int CAS = 101;
    while (CAS--) {
      for (int i = 1; i <= n; i++) c[++cnt] = c[i];
    }
    n = cnt;
    memset(a, 0, sizeof a);
    for (int i = 1; i <= n; i++) {
      f[i] = 1 + qry(c[i]);
      insert(c[i], f[i]);
    }
    for (int i = 1; i <= n; i++) {
      c[i] = 300 - c[i] + 1;
    }
    memset(a, 0, sizeof a);
    for (int i = n; i >= 1; i--) {
      g[i] = 1 + qry(c[i]);
      insert(c[i], g[i]);
    }
    long long ans = 1;
    T -= 102;
    T -= 102;
    for (int i = 1; i <= n; i++) {
      c[i] = 300 - c[i] + 1;
    }
    for (int i = 1; i <= n; i++) {
      ans = max(ans, f[i] + g[tt[(i - 1) % nn]] + (long long)T * cc[c[i]]);
    }
    printf("%I64d\n", ans);
  }
  if (ttt) return 0;
  return 0;
}

### Prompt

Please formulate 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 a[305];
int c[200010];
int f[200010], g[200010];
int cc[305], tt[305];
int n, T;
inline int lowbit(int x) { return x & (-x); }
void insert(int p, int c) {
  while (p <= 305) {
    a[p] = max(a[p], c);
    p += lowbit(p);
  }
}
int qry(int p) {
  int ans = 0;
  while (p > 0) {
    ans = max(ans, a[p]);
    p -= lowbit(p);
  }
  return ans;
}
int main() {
  int ttt = 9;
  scanf("%d%d", &n, &T);
  for (int i = 1; i <= n; i++) scanf("%d", &c[i]);
  if (T < 1000) {
    ttt++;
    int cnt = n;
    int CAS = T - 1;
    while (CAS--) {
      for (int i = 1; i <= n; i++) c[++cnt] = c[i];
    }
    n = cnt;
    memset(a, 0, sizeof a);
    int ans = 1;
    for (int i = 1; i <= n; i++) {
      f[i] = 1 + qry(c[i]);
      ans = max(ans, f[i]);
      insert(c[i], f[i]);
    }
    printf("%d\n", ans);
  } else {
    for (int i = 1; i <= n; i++) cc[c[i]]++;
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++)
        if (c[i] == c[j]) {
          tt[i - 1] = j;
          break;
        }
    ttt++;
    int cnt = n;
    int nn = n;
    int CAS = 101;
    while (CAS--) {
      for (int i = 1; i <= n; i++) c[++cnt] = c[i];
    }
    n = cnt;
    memset(a, 0, sizeof a);
    for (int i = 1; i <= n; i++) {
      f[i] = 1 + qry(c[i]);
      insert(c[i], f[i]);
    }
    for (int i = 1; i <= n; i++) {
      c[i] = 300 - c[i] + 1;
    }
    memset(a, 0, sizeof a);
    for (int i = n; i >= 1; i--) {
      g[i] = 1 + qry(c[i]);
      insert(c[i], g[i]);
    }
    long long ans = 1;
    T -= 102;
    T -= 102;
    for (int i = 1; i <= n; i++) {
      c[i] = 300 - c[i] + 1;
    }
    for (int i = 1; i <= n; i++) {
      ans = max(ans, f[i] + g[tt[(i - 1) % nn]] + (long long)T * cc[c[i]]);
    }
    printf("%I64d\n", ans);
  }
  if (ttt) return 0;
  return 0;
}

```