#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, long long> > lis(
    const vector<pair<long long, long long> >& v) {
  vector<long long> endsIndex;
  vector<long long> prevIndex(v.size(), -1);
  vector<pair<long long, long long> > rLIS;
  endsIndex.push_back(0);
  for (int x = 0; x < (int)v.size(); x++) {
    if (v[x] < v[endsIndex[0]])
      endsIndex[0] = x;
    else if (v[x] > v[endsIndex[endsIndex.size() - 1]]) {
      prevIndex[x] = endsIndex[endsIndex.size() - 1];
      endsIndex.push_back(x);
    } else {
      if (v[x] == v[endsIndex[endsIndex.size() - 1]]) continue;
      int i = -1;
      int lo = 0, hi = endsIndex.size() - 1;
      while (lo <= hi) {
        int mid = (lo + hi) / 2;
        if (v[x] == v[endsIndex[mid]]) {
          i = mid - 1;
          break;
        } else if (v[x] < v[endsIndex[mid]]) {
          hi = mid - 1;
        } else {
          lo = mid + 1;
        }
      }
      if (i == -1) i = hi;
      if (i < 0) continue;
      if (i >= (int)endsIndex.size() - 1) continue;
      endsIndex[i + 1] = x;
      prevIndex[x] = endsIndex[i];
    }
  }
  for (int x = endsIndex[endsIndex.size() - 1]; x >= 0; x = prevIndex[x])
    if (x >= 0) rLIS.push_back(v[x]);
  reverse(rLIS.begin(), rLIS.end());
  return rLIS;
}
int c[305];
int main() {
  int n;
  cin >> n;
  int m;
  cin >> m;
  vector<pair<long long, long long> > v(n);
  for (int x = 0; x < n; x++) {
    cin >> v[x].first;
    v[x].second = x;
    c[v[x].first]++;
  }
  int max1 = -1;
  for (int x = 0; x < 305; x++) max1 = max(max1, c[x]);
  int m1 = min(m, 1000);
  m -= m1;
  vector<pair<long long, long long> > v2(n * m1);
  for (int x = 0; x < n * m1; x++) {
    v2[x] = v[x % n];
    v2[x].second = x;
  }
  cout << lis(v2).size() + max1 * m << endl;
}

### Prompt

Your challenge is to write 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;
vector<pair<long long, long long> > lis(
    const vector<pair<long long, long long> >& v) {
  vector<long long> endsIndex;
  vector<long long> prevIndex(v.size(), -1);
  vector<pair<long long, long long> > rLIS;
  endsIndex.push_back(0);
  for (int x = 0; x < (int)v.size(); x++) {
    if (v[x] < v[endsIndex[0]])
      endsIndex[0] = x;
    else if (v[x] > v[endsIndex[endsIndex.size() - 1]]) {
      prevIndex[x] = endsIndex[endsIndex.size() - 1];
      endsIndex.push_back(x);
    } else {
      if (v[x] == v[endsIndex[endsIndex.size() - 1]]) continue;
      int i = -1;
      int lo = 0, hi = endsIndex.size() - 1;
      while (lo <= hi) {
        int mid = (lo + hi) / 2;
        if (v[x] == v[endsIndex[mid]]) {
          i = mid - 1;
          break;
        } else if (v[x] < v[endsIndex[mid]]) {
          hi = mid - 1;
        } else {
          lo = mid + 1;
        }
      }
      if (i == -1) i = hi;
      if (i < 0) continue;
      if (i >= (int)endsIndex.size() - 1) continue;
      endsIndex[i + 1] = x;
      prevIndex[x] = endsIndex[i];
    }
  }
  for (int x = endsIndex[endsIndex.size() - 1]; x >= 0; x = prevIndex[x])
    if (x >= 0) rLIS.push_back(v[x]);
  reverse(rLIS.begin(), rLIS.end());
  return rLIS;
}
int c[305];
int main() {
  int n;
  cin >> n;
  int m;
  cin >> m;
  vector<pair<long long, long long> > v(n);
  for (int x = 0; x < n; x++) {
    cin >> v[x].first;
    v[x].second = x;
    c[v[x].first]++;
  }
  int max1 = -1;
  for (int x = 0; x < 305; x++) max1 = max(max1, c[x]);
  int m1 = min(m, 1000);
  m -= m1;
  vector<pair<long long, long long> > v2(n * m1);
  for (int x = 0; x < n * m1; x++) {
    v2[x] = v[x % n];
    v2[x].second = x;
  }
  cout << lis(v2).size() + max1 * m << endl;
}

```