#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0;
  char c = getchar();
  while (!isdigit(c)) c = getchar();
  while (isdigit(c)) x = x * 10 + c - '0', c = getchar();
  return x;
}
const int maxn = 100;
int a[maxn * 300], f[maxn * 300], d[maxn * 300];
int bsearch(const int *f, int size, const int &a) {
  int l = 0, r = size - 1;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (a >= d[mid - 1] && a < d[mid])
      return mid;
    else if (a < d[mid])
      r = mid - 1;
    else
      l = mid + 1;
  }
}
int LIS(const int *a, const int &n) {
  int i, j, size = 1;
  d[0] = a[0];
  f[0] = 1;
  for (i = 1; i < n; ++i) {
    if (a[i] < d[0])
      j = 0;
    else if (a[i] >= d[size - 1])
      j = size++;
    else
      j = bsearch(d, size, a[i]);
    d[j] = a[i];
    f[i] = j + 1;
  }
  return size;
}
int main() {
  int n = read(), T = read();
  int rep = min(T, 300), len = rep * n;
  for (int i = 0; i < n; i++) {
    a[i] = read();
    for (int j = 1; j < rep; j++) a[i + j * n] = a[i];
  }
  LIS(a, len);
  int ans = 0;
  for (int i = 1; i <= n; i++) ans = max(ans, f[len - i]);
  if (rep != T) {
    int x = 0;
    for (int i = 1; i <= n; i++) x = max(x, f[len - i] - f[len - n - i]);
    ans = ans + x * (T - 300);
  }
  printf("%d", ans);
  return 0;
}

### Prompt

Please provide a CPP coded solution to the problem described below:

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;
inline int read() {
  int x = 0;
  char c = getchar();
  while (!isdigit(c)) c = getchar();
  while (isdigit(c)) x = x * 10 + c - '0', c = getchar();
  return x;
}
const int maxn = 100;
int a[maxn * 300], f[maxn * 300], d[maxn * 300];
int bsearch(const int *f, int size, const int &a) {
  int l = 0, r = size - 1;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (a >= d[mid - 1] && a < d[mid])
      return mid;
    else if (a < d[mid])
      r = mid - 1;
    else
      l = mid + 1;
  }
}
int LIS(const int *a, const int &n) {
  int i, j, size = 1;
  d[0] = a[0];
  f[0] = 1;
  for (i = 1; i < n; ++i) {
    if (a[i] < d[0])
      j = 0;
    else if (a[i] >= d[size - 1])
      j = size++;
    else
      j = bsearch(d, size, a[i]);
    d[j] = a[i];
    f[i] = j + 1;
  }
  return size;
}
int main() {
  int n = read(), T = read();
  int rep = min(T, 300), len = rep * n;
  for (int i = 0; i < n; i++) {
    a[i] = read();
    for (int j = 1; j < rep; j++) a[i + j * n] = a[i];
  }
  LIS(a, len);
  int ans = 0;
  for (int i = 1; i <= n; i++) ans = max(ans, f[len - i]);
  if (rep != T) {
    int x = 0;
    for (int i = 1; i <= n; i++) x = max(x, f[len - i] - f[len - n - i]);
    ans = ans + x * (T - 300);
  }
  printf("%d", ans);
  return 0;
}

```