#include <bits/stdc++.h>
using namespace std;
int a[3225020];
int dp1[3225020];
int dp2[3225020];
int dp3[3225020];
int lis[3][3225020];
int main() {
  int n, t;
  scanf("%d%d", &n, &t);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  if (t <= 300) {
    int ans = 0;
    for (int i = 1; i <= n; i++)
      for (int j = 1; j < t; j++) a[j * n + i] = a[i];
    for (int i = 1; i <= n * t; i++) {
      lis[0][i] = 1;
      for (int j = 1; j < i; j++)
        if (a[i] >= a[j]) lis[0][i] = max(lis[0][i], lis[0][j] + 1);
      ans = max(lis[0][i], ans);
    }
    printf("%d\n", ans);
    return 0;
  }
  memset(lis, 0, sizeof(lis));
  int k = n;
  for (int i = 1; i <= n; i++) dp2[a[i]]++;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= k; j++) a[j * n + i] = a[i];
  int cnt = 0;
  for (int i = 1; i <= k; ++i) {
    int now = i & 1;
    for (int j = 1; j <= n; ++j) {
      lis[now][j] = 1;
      for (int q = 1; q < j; ++q) {
        if (a[q] <= a[j]) lis[now][j] = max(lis[now][j], lis[now][q] + 1);
      }
      for (int q = 1; q <= n; ++q) {
        if (a[q] <= a[j]) lis[now][j] = max(lis[now][j], lis[now ^ 1][q] + 1);
      }
      if (i == k) {
        dp1[a[j]] = max(dp1[a[j]], lis[now][j]);
      }
    }
  }
  memset(lis[2], 0, sizeof(lis[2]));
  reverse(a + 1, a + 1 + k * n);
  cnt = 0;
  for (int i = 1; i <= k * n; i++) {
    lis[2][i] = 1;
    for (int j = max(1, n * (cnt - 1) + 1); j < i; j++)
      if (a[i] <= a[j]) lis[2][i] = max(lis[2][i], lis[2][j] + 1);
    if (i % n == 0) cnt++;
    if (i > n * (n - 1)) dp3[a[i]] = max(dp3[a[i]], lis[2][i]);
  }
  int ans = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j <= 300; j++)
      for (int m = j; m <= 300; m++)
        if (a[i] <= j)
          ans = max(lis[k & 1][n + 1 - i] + dp2[j] * (t - 2 * k) + dp3[m], ans);
  printf("%d\n", ans);
}

### Prompt

Your task is to create 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[3225020];
int dp1[3225020];
int dp2[3225020];
int dp3[3225020];
int lis[3][3225020];
int main() {
  int n, t;
  scanf("%d%d", &n, &t);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  if (t <= 300) {
    int ans = 0;
    for (int i = 1; i <= n; i++)
      for (int j = 1; j < t; j++) a[j * n + i] = a[i];
    for (int i = 1; i <= n * t; i++) {
      lis[0][i] = 1;
      for (int j = 1; j < i; j++)
        if (a[i] >= a[j]) lis[0][i] = max(lis[0][i], lis[0][j] + 1);
      ans = max(lis[0][i], ans);
    }
    printf("%d\n", ans);
    return 0;
  }
  memset(lis, 0, sizeof(lis));
  int k = n;
  for (int i = 1; i <= n; i++) dp2[a[i]]++;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= k; j++) a[j * n + i] = a[i];
  int cnt = 0;
  for (int i = 1; i <= k; ++i) {
    int now = i & 1;
    for (int j = 1; j <= n; ++j) {
      lis[now][j] = 1;
      for (int q = 1; q < j; ++q) {
        if (a[q] <= a[j]) lis[now][j] = max(lis[now][j], lis[now][q] + 1);
      }
      for (int q = 1; q <= n; ++q) {
        if (a[q] <= a[j]) lis[now][j] = max(lis[now][j], lis[now ^ 1][q] + 1);
      }
      if (i == k) {
        dp1[a[j]] = max(dp1[a[j]], lis[now][j]);
      }
    }
  }
  memset(lis[2], 0, sizeof(lis[2]));
  reverse(a + 1, a + 1 + k * n);
  cnt = 0;
  for (int i = 1; i <= k * n; i++) {
    lis[2][i] = 1;
    for (int j = max(1, n * (cnt - 1) + 1); j < i; j++)
      if (a[i] <= a[j]) lis[2][i] = max(lis[2][i], lis[2][j] + 1);
    if (i % n == 0) cnt++;
    if (i > n * (n - 1)) dp3[a[i]] = max(dp3[a[i]], lis[2][i]);
  }
  int ans = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j <= 300; j++)
      for (int m = j; m <= 300; m++)
        if (a[i] <= j)
          ans = max(lis[k & 1][n + 1 - i] + dp2[j] * (t - 2 * k) + dp3[m], ans);
  printf("%d\n", ans);
}

```