#include <bits/stdc++.h>
using namespace std;
vector<int> input;
int s[10005];
int binary_search(int first, int last, int x) {
  while (last > first) {
    int mid = first + (last - first) / 2;
    if (input[s[mid]] > x)
      last = mid;
    else
      first = mid + 1;
  }
  return first;
}
int longest_increasing_subsequence_nlgn(int n) {
  int i, k, index;
  memset(s, 0, sizeof(s));
  index = 1;
  s[1] = 0;
  for (i = 1; i < n; i++) {
    if (input[i] >= input[s[index]]) {
      index++;
      s[index] = i;
    } else {
      k = binary_search(1, index, input[i]);
      if (input[s[k]] >= input[i]) {
        s[k] = i;
      }
    }
  }
  return index;
}
int main() {
  int n, t;
  cin >> n >> t;
  int i;
  int hash[305] = {0};
  for (i = 0; i < n; i++) {
    int x;
    cin >> x;
    input.push_back(x);
    hash[x]++;
  }
  int tmin = min(t, 100);
  tmin--;
  while (tmin--) {
    for (i = 0; i < n; i++) {
      input.push_back(input[i]);
    }
  }
  int val = longest_increasing_subsequence_nlgn(n * min(t, 100));
  if (t <= 100) {
    cout << val << endl;
  } else {
    int maxVal = INT_MIN;
    for (i = 1; i <= 300; i++) {
      maxVal = max(maxVal, hash[i]);
    }
    cout << val + ((long long int)t - 100) * maxVal;
  }
  return 0;
}

### Prompt

Construct a CPP code solution to the problem outlined:

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;
vector<int> input;
int s[10005];
int binary_search(int first, int last, int x) {
  while (last > first) {
    int mid = first + (last - first) / 2;
    if (input[s[mid]] > x)
      last = mid;
    else
      first = mid + 1;
  }
  return first;
}
int longest_increasing_subsequence_nlgn(int n) {
  int i, k, index;
  memset(s, 0, sizeof(s));
  index = 1;
  s[1] = 0;
  for (i = 1; i < n; i++) {
    if (input[i] >= input[s[index]]) {
      index++;
      s[index] = i;
    } else {
      k = binary_search(1, index, input[i]);
      if (input[s[k]] >= input[i]) {
        s[k] = i;
      }
    }
  }
  return index;
}
int main() {
  int n, t;
  cin >> n >> t;
  int i;
  int hash[305] = {0};
  for (i = 0; i < n; i++) {
    int x;
    cin >> x;
    input.push_back(x);
    hash[x]++;
  }
  int tmin = min(t, 100);
  tmin--;
  while (tmin--) {
    for (i = 0; i < n; i++) {
      input.push_back(input[i]);
    }
  }
  int val = longest_increasing_subsequence_nlgn(n * min(t, 100));
  if (t <= 100) {
    cout << val << endl;
  } else {
    int maxVal = INT_MIN;
    for (i = 1; i <= 300; i++) {
      maxVal = max(maxVal, hash[i]);
    }
    cout << val + ((long long int)t - 100) * maxVal;
  }
  return 0;
}

```