#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100000 + 10, INF = 0x7f7f7f7f;
int a[MAXN];
int cnt[1000];
int mn[MAXN];
int main() {
  int n, T;
  scanf("%d%d", &n, &T);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  memset(cnt, 0, sizeof(cnt));
  int mx = 0, maxx = 0;
  for (int i = 1; i <= n; ++i) {
    ++cnt[a[i]];
    mx = max(mx, a[i]);
  }
  for (int i = 1; i <= mx; ++i) maxx = max(maxx, cnt[i]);
  int ans = 0;
  if (T > 1000) {
    ans = maxx * (T - 1000);
    T = 1000;
  }
  int tot = n;
  for (int i = 2; i <= T; ++i)
    for (int j = 1; j <= n; ++j) a[++tot] = a[j];
  int top = 1;
  mn[0] = 0;
  mn[1] = a[1];
  mn[2] = INF;
  for (int i = 2; i <= tot; ++i) {
    int l = 0, r = top + 1;
    while (l + 1 < r) {
      int mid = (l + r) >> 1;
      if (mn[mid] <= a[i])
        l = mid;
      else
        r = mid;
    }
    mn[r] = a[i];
    if (r > top) {
      ++top;
      mn[top + 1] = INF;
    }
  }
  ans += top;
  printf("%d\n", ans);
  return 0;
}

### Prompt

Develop a solution in Cpp 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;
const int MAXN = 100000 + 10, INF = 0x7f7f7f7f;
int a[MAXN];
int cnt[1000];
int mn[MAXN];
int main() {
  int n, T;
  scanf("%d%d", &n, &T);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  memset(cnt, 0, sizeof(cnt));
  int mx = 0, maxx = 0;
  for (int i = 1; i <= n; ++i) {
    ++cnt[a[i]];
    mx = max(mx, a[i]);
  }
  for (int i = 1; i <= mx; ++i) maxx = max(maxx, cnt[i]);
  int ans = 0;
  if (T > 1000) {
    ans = maxx * (T - 1000);
    T = 1000;
  }
  int tot = n;
  for (int i = 2; i <= T; ++i)
    for (int j = 1; j <= n; ++j) a[++tot] = a[j];
  int top = 1;
  mn[0] = 0;
  mn[1] = a[1];
  mn[2] = INF;
  for (int i = 2; i <= tot; ++i) {
    int l = 0, r = top + 1;
    while (l + 1 < r) {
      int mid = (l + r) >> 1;
      if (mn[mid] <= a[i])
        l = mid;
      else
        r = mid;
    }
    mn[r] = a[i];
    if (r > top) {
      ++top;
      mn[top + 1] = INF;
    }
  }
  ans += top;
  printf("%d\n", ans);
  return 0;
}

```