#include <bits/stdc++.h>
using namespace std;
const int64_t INF = (int64_t)(2e18);
const long long inf = (long long)(1e9 + 7);
const long long maxn = 500 * 1000 + 100;
chrono::time_point<chrono::steady_clock> cl;
double current_time() {
  return (chrono::steady_clock::now() - cl).count() / 1e9;
}
vector<vector<long long>> mat;
vector<vector<long long>> operator*(vector<vector<long long>> a,
                                    vector<vector<long long>> b) {
  long long n = (long long)a.size();
  vector<vector<long long>> res(n, vector<long long>(n, -INF));
  for (long long i = 0; i < n; ++i) {
    for (long long j = 0; j < n; ++j) {
      for (long long k = 0; k < n; ++k) {
        res[i][j] = max(res[i][j], a[i][k] + b[k][j]);
      }
    }
  }
  return res;
}
vector<vector<long long>> binpow(vector<vector<long long>> a, long long p) {
  vector<vector<long long>> res(a.size(), vector<long long>(a.size(), 0));
  for (; p; p /= 2) {
    if (p & 1) res = res * a;
    a = a * a;
  }
  return res;
}
int32_t main() {
  cl = chrono::steady_clock::now();
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  cin.tie(nullptr);
  long long n;
  cin >> n;
  long long t;
  cin >> t;
  vector<long long> xs;
  vector<long long> ar(n);
  for (auto& it : ar) cin >> it;
  for (auto& it : ar) xs.push_back(it);
  sort((xs).begin(), (xs).end());
  xs.resize(unique((xs).begin(), (xs).end()) - begin(xs));
  for (auto& it : ar)
    it = lower_bound((xs).begin(), (xs).end(), it) - begin(xs);
  mat.resize(xs.size(), vector<long long>(xs.size(), -INF));
  for (long long i = 0; i < (long long)xs.size(); ++i) {
    for (long long j = i; j < (long long)xs.size(); ++j) {
      vector<long long> dp(xs.size(), -1);
      dp[i] = 0;
      for (auto& it : ar) {
        if (it < i) continue;
        if (it > j) continue;
        for (long long k = it; k >= 0; --k) {
          dp[it] = max(dp[it], dp[k] + 1);
        }
      }
      if (dp[j] == -1)
        continue;
      else
        mat[i][j] = dp[j];
    }
  }
  mat = binpow(mat, t);
  long long res = 0;
  for (auto& it : mat) {
    for (auto& itt : it) res = max(res, itt);
  }
  cout << res << endl;
  return 0;
}

### Prompt

Please create a solution in CPP 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;
const int64_t INF = (int64_t)(2e18);
const long long inf = (long long)(1e9 + 7);
const long long maxn = 500 * 1000 + 100;
chrono::time_point<chrono::steady_clock> cl;
double current_time() {
  return (chrono::steady_clock::now() - cl).count() / 1e9;
}
vector<vector<long long>> mat;
vector<vector<long long>> operator*(vector<vector<long long>> a,
                                    vector<vector<long long>> b) {
  long long n = (long long)a.size();
  vector<vector<long long>> res(n, vector<long long>(n, -INF));
  for (long long i = 0; i < n; ++i) {
    for (long long j = 0; j < n; ++j) {
      for (long long k = 0; k < n; ++k) {
        res[i][j] = max(res[i][j], a[i][k] + b[k][j]);
      }
    }
  }
  return res;
}
vector<vector<long long>> binpow(vector<vector<long long>> a, long long p) {
  vector<vector<long long>> res(a.size(), vector<long long>(a.size(), 0));
  for (; p; p /= 2) {
    if (p & 1) res = res * a;
    a = a * a;
  }
  return res;
}
int32_t main() {
  cl = chrono::steady_clock::now();
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  cin.tie(nullptr);
  long long n;
  cin >> n;
  long long t;
  cin >> t;
  vector<long long> xs;
  vector<long long> ar(n);
  for (auto& it : ar) cin >> it;
  for (auto& it : ar) xs.push_back(it);
  sort((xs).begin(), (xs).end());
  xs.resize(unique((xs).begin(), (xs).end()) - begin(xs));
  for (auto& it : ar)
    it = lower_bound((xs).begin(), (xs).end(), it) - begin(xs);
  mat.resize(xs.size(), vector<long long>(xs.size(), -INF));
  for (long long i = 0; i < (long long)xs.size(); ++i) {
    for (long long j = i; j < (long long)xs.size(); ++j) {
      vector<long long> dp(xs.size(), -1);
      dp[i] = 0;
      for (auto& it : ar) {
        if (it < i) continue;
        if (it > j) continue;
        for (long long k = it; k >= 0; --k) {
          dp[it] = max(dp[it], dp[k] + 1);
        }
      }
      if (dp[j] == -1)
        continue;
      else
        mat[i][j] = dp[j];
    }
  }
  mat = binpow(mat, t);
  long long res = 0;
  for (auto& it : mat) {
    for (auto& itt : it) res = max(res, itt);
  }
  cout << res << endl;
  return 0;
}

```