#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL), cout.tie(NULL);
  int n, t;
  cin >> n >> t;
  vector<int> vec2(n);
  for (auto& x : vec2) cin >> x;
  long long ans = 0;
  int tm = 100;
  int S = n * min(t, tm);
  vector<int> vec(S);
  for (int j = 0; j < min(t, tm); j++) {
    for (int i = 0; i < n; i++) vec[j * n + i] = vec2[i];
  }
  vector<int> LIS_S(S);
  vector<int> LIS_E(S);
  for (int i = 0; i < S; i++) {
    LIS_S[i] = 1;
    for (int j = i - 1; j >= 0; j--) {
      if (vec[j] <= vec[i]) LIS_S[i] = max(LIS_S[i], LIS_S[j] + 1);
    }
  }
  for (int i = S - 1; i >= 0; i--) {
    LIS_E[i] = 1;
    for (int j = i + 1; j < S; j++) {
      if (vec[j] >= vec[i]) LIS_E[i] = max(LIS_E[i], LIS_E[j] + 1);
    }
  }
  map<int, int> counts;
  for (auto& x : vec2) counts[x]++;
  if (t <= tm) {
    cout << *max_element(LIS_S.begin(), LIS_S.end()) << '\n';
  } else {
    for (auto& p : counts) {
      int x = p.first;
      long long c = p.second;
      long long a = 0;
      for (int i = S - (n * (tm / 2)) - 1; i >= 0; i--) {
        if (vec[i] == x) {
          a += LIS_S[i];
          break;
        }
      }
      if (t > tm) {
        a += c * (t - tm);
      }
      for (int i = n * (tm / 2); i < S; i++) {
        if (vec[i] == x) {
          a += LIS_E[i];
          break;
        }
      }
      ans = max(ans, a);
    }
    cout << ans << '\n';
  }
}

### Prompt

Please formulate 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 main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL), cout.tie(NULL);
  int n, t;
  cin >> n >> t;
  vector<int> vec2(n);
  for (auto& x : vec2) cin >> x;
  long long ans = 0;
  int tm = 100;
  int S = n * min(t, tm);
  vector<int> vec(S);
  for (int j = 0; j < min(t, tm); j++) {
    for (int i = 0; i < n; i++) vec[j * n + i] = vec2[i];
  }
  vector<int> LIS_S(S);
  vector<int> LIS_E(S);
  for (int i = 0; i < S; i++) {
    LIS_S[i] = 1;
    for (int j = i - 1; j >= 0; j--) {
      if (vec[j] <= vec[i]) LIS_S[i] = max(LIS_S[i], LIS_S[j] + 1);
    }
  }
  for (int i = S - 1; i >= 0; i--) {
    LIS_E[i] = 1;
    for (int j = i + 1; j < S; j++) {
      if (vec[j] >= vec[i]) LIS_E[i] = max(LIS_E[i], LIS_E[j] + 1);
    }
  }
  map<int, int> counts;
  for (auto& x : vec2) counts[x]++;
  if (t <= tm) {
    cout << *max_element(LIS_S.begin(), LIS_S.end()) << '\n';
  } else {
    for (auto& p : counts) {
      int x = p.first;
      long long c = p.second;
      long long a = 0;
      for (int i = S - (n * (tm / 2)) - 1; i >= 0; i--) {
        if (vec[i] == x) {
          a += LIS_S[i];
          break;
        }
      }
      if (t > tm) {
        a += c * (t - tm);
      }
      for (int i = n * (tm / 2); i < S; i++) {
        if (vec[i] == x) {
          a += LIS_E[i];
          break;
        }
      }
      ans = max(ans, a);
    }
    cout << ans << '\n';
  }
}

```