#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int a[N], f[N], d[N];
int bsearch(const int *f, int size, const int &a) {
  int l = 0, r = size - 1;
  while (l <= r) {
    int mid = (l + r) / 2;
    if (a >= f[mid - 1] && a < f[mid])
      return mid;
    else if (a < f[mid])
      r = mid - 1;
    else
      l = mid + 1;
  }
}
int LIS(const int *a, const int &n) {
  int i, j, size = 1;
  f[0] = a[0];
  d[0] = 1;
  for (i = 1; i < n; ++i) {
    if (a[i] < f[0])
      j = 0;
    else if (a[i] >= f[size - 1])
      j = size++;
    else
      j = bsearch(f, size, a[i]);
    f[j] = a[i];
    d[i] = j + 1;
  }
  return size;
}
void gao(int n, int m, int t) {
  int ans = LIS(a, n * m);
  sort(a, a + n);
  int maxx = 0, max_v = 0, cnt = 1;
  for (int i = 1; i < n; ++i) {
    if (a[i] == a[i - 1])
      ++cnt;
    else {
      if (cnt > maxx || (cnt == maxx && max_v <= a[i])) {
        maxx = cnt;
        max_v = a[i];
      }
      cnt = 1;
    }
  }
  maxx = max(maxx, cnt);
  int add = 0;
  printf("%d\n", ans + maxx * (t - m) + add);
}
int main() {
  int n, t;
  scanf("%d%d", &n, &t);
  for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
  int m = min(n, t);
  for (int i = 1; i < m; ++i)
    for (int j = 0; j < n; ++j) a[i * n + j] = a[j];
  gao(n, m, t);
  return 0;
}

### Prompt

Your challenge is to write 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 = 1e6 + 5;
int a[N], f[N], d[N];
int bsearch(const int *f, int size, const int &a) {
  int l = 0, r = size - 1;
  while (l <= r) {
    int mid = (l + r) / 2;
    if (a >= f[mid - 1] && a < f[mid])
      return mid;
    else if (a < f[mid])
      r = mid - 1;
    else
      l = mid + 1;
  }
}
int LIS(const int *a, const int &n) {
  int i, j, size = 1;
  f[0] = a[0];
  d[0] = 1;
  for (i = 1; i < n; ++i) {
    if (a[i] < f[0])
      j = 0;
    else if (a[i] >= f[size - 1])
      j = size++;
    else
      j = bsearch(f, size, a[i]);
    f[j] = a[i];
    d[i] = j + 1;
  }
  return size;
}
void gao(int n, int m, int t) {
  int ans = LIS(a, n * m);
  sort(a, a + n);
  int maxx = 0, max_v = 0, cnt = 1;
  for (int i = 1; i < n; ++i) {
    if (a[i] == a[i - 1])
      ++cnt;
    else {
      if (cnt > maxx || (cnt == maxx && max_v <= a[i])) {
        maxx = cnt;
        max_v = a[i];
      }
      cnt = 1;
    }
  }
  maxx = max(maxx, cnt);
  int add = 0;
  printf("%d\n", ans + maxx * (t - m) + add);
}
int main() {
  int n, t;
  scanf("%d%d", &n, &t);
  for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
  int m = min(n, t);
  for (int i = 1; i < m; ++i)
    for (int j = 0; j < n; ++j) a[i * n + j] = a[j];
  gao(n, m, t);
  return 0;
}

```