#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9, MOD = INF + 7;
const int N = 1e2 + 5;
int a[N];
struct Matrix {
  int n, m, A[N][N];
  inline Matrix(int _n, int _m) : n(_n), m(_m) { memset(A, 0, sizeof(A)); }
  inline Matrix operator*(Matrix &X) {
    assert(m == X.n);
    Matrix R(n, X.m);
    for (int i = 0; i < n; i++)
      for (int j = 0; j < X.m; j++) R[i][j] = -INF;
    for (int i = 0; i < n; i++)
      for (int k = 0; k < m; k++)
        for (int j = 0; j < X.m; j++) R[i][j] = max(R[i][j], A[i][k] + X[k][j]);
    return (R);
  }
  inline Matrix operator^(long long pw) {
    assert(n == m);
    Matrix R(n, n), T = *this;
    for (int i = 0; i < n; i++)
      for (int i = 0; i < n; i++) R[i][i] = 0;
    for (; pw; pw >>= 1, T = T * T)
      if (pw & 1) R = R * T;
    return (R);
  }
  inline int *operator[](int i) { return A[i]; }
};
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, t;
  cin >> n >> t;
  Matrix g(n, n);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      if (a[i] > a[j])
        g[i][j] = -INF;
      else {
        g[i][j] = 1;
        for (int k = 0; k < j; k++)
          if (a[k] <= a[j]) g[i][j] = max(g[i][j], g[i][k] + 1);
      }
    }
  g = g ^ t;
  int ans = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) ans = max(ans, g[i][j]);
  cout << ans << "\n";
  return 0;
}

### Prompt

Please provide a cpp coded solution to the problem described below:

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 long long INF = 1e9, MOD = INF + 7;
const int N = 1e2 + 5;
int a[N];
struct Matrix {
  int n, m, A[N][N];
  inline Matrix(int _n, int _m) : n(_n), m(_m) { memset(A, 0, sizeof(A)); }
  inline Matrix operator*(Matrix &X) {
    assert(m == X.n);
    Matrix R(n, X.m);
    for (int i = 0; i < n; i++)
      for (int j = 0; j < X.m; j++) R[i][j] = -INF;
    for (int i = 0; i < n; i++)
      for (int k = 0; k < m; k++)
        for (int j = 0; j < X.m; j++) R[i][j] = max(R[i][j], A[i][k] + X[k][j]);
    return (R);
  }
  inline Matrix operator^(long long pw) {
    assert(n == m);
    Matrix R(n, n), T = *this;
    for (int i = 0; i < n; i++)
      for (int i = 0; i < n; i++) R[i][i] = 0;
    for (; pw; pw >>= 1, T = T * T)
      if (pw & 1) R = R * T;
    return (R);
  }
  inline int *operator[](int i) { return A[i]; }
};
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, t;
  cin >> n >> t;
  Matrix g(n, n);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      if (a[i] > a[j])
        g[i][j] = -INF;
      else {
        g[i][j] = 1;
        for (int k = 0; k < j; k++)
          if (a[k] <= a[j]) g[i][j] = max(g[i][j], g[i][k] + 1);
      }
    }
  g = g ^ t;
  int ans = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) ans = max(ans, g[i][j]);
  cout << ans << "\n";
  return 0;
}

```