#include <bits/stdc++.h>
using namespace std;
int S[10010000];
int a[10010000];
int d[10010000];
int BSearch(int x, int y, int v) {
  while (x <= y) {
    int mid = x + (y - x) / 2;
    if (S[mid] <= v)
      x = mid + 1;
    else
      y = mid - 1;
  }
  return x;
}
int dp(int m) {
  for (int i = 1; i <= m; i++) S[i] = 1e9 + 100;
  int ans = 0;
  for (int i = 1; i <= m; i++) {
    int x = 1, y = i;
    int pos = BSearch(x, y, a[i]);
    d[i] = pos;
    S[d[i]] = min(S[d[i]], a[i]);
    ans = max(ans, d[i]);
  }
  return ans;
}
int main() {
  int n;
  int t;
  scanf("%d%d", &n, &t);
  int vis[500] = {0};
  int maxTime = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    vis[a[i]]++;
    maxTime = max(maxTime, vis[a[i]]);
  }
  int m = n;
  int _time = min(t, n * n * 10);
  for (int j = 1; j <= _time - 1; j++) {
    for (int i = 1; i <= n; i++) {
      a[++m] = a[i];
    }
  }
  int ans = dp(m);
  if (t > n * n * 10) {
    ans += (t - n * n * 10) * maxTime;
    cout << ans << endl;
    return 0;
  }
  cout << ans << endl;
  return 0;
}

### Prompt

In CPP, your task is to solve 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 S[10010000];
int a[10010000];
int d[10010000];
int BSearch(int x, int y, int v) {
  while (x <= y) {
    int mid = x + (y - x) / 2;
    if (S[mid] <= v)
      x = mid + 1;
    else
      y = mid - 1;
  }
  return x;
}
int dp(int m) {
  for (int i = 1; i <= m; i++) S[i] = 1e9 + 100;
  int ans = 0;
  for (int i = 1; i <= m; i++) {
    int x = 1, y = i;
    int pos = BSearch(x, y, a[i]);
    d[i] = pos;
    S[d[i]] = min(S[d[i]], a[i]);
    ans = max(ans, d[i]);
  }
  return ans;
}
int main() {
  int n;
  int t;
  scanf("%d%d", &n, &t);
  int vis[500] = {0};
  int maxTime = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    vis[a[i]]++;
    maxTime = max(maxTime, vis[a[i]]);
  }
  int m = n;
  int _time = min(t, n * n * 10);
  for (int j = 1; j <= _time - 1; j++) {
    for (int i = 1; i <= n; i++) {
      a[++m] = a[i];
    }
  }
  int ans = dp(m);
  if (t > n * n * 10) {
    ans += (t - n * n * 10) * maxTime;
    cout << ans << endl;
    return 0;
  }
  cout << ans << endl;
  return 0;
}

```